When I turn my Android phone up, my activity does not rotate to show the layout upside down, but remains in landscape mode. I tried this with a very simple HelloWorld application. I added android:configChanges="orientation"to the manifest and turned it over onConfigurationChange()to Activity to set breakpoints there. Turning the device upside down causes one configuration change to go from portrait (up) to landscape, but without a second change from landscape to portrait (upside down). Is this a problem with Android or is there something I need to do?
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hello.world"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:configChanges="orientation"
android:name=".HelloWorldActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Activity:
public class HelloWorldActivity
extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
Log.e("MDO", "orientation change: landscape");
}
else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
{
Log.e("MDO", "orientation change: portrait");
}
}
}
source
share