I'm trying to launch MyActivity in landscape mode. The problem is that it is currently being launched in portrait mode an then it goes to landscape mode.
I have defined MyActivity in AndroidManifest.xml like this:
<activity
android:name="com.myproject.MyActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:screenOrientation="landscape"
android:taskAffinity="com.myproject"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
Is there any way to force the activity to be launched right into landscape mode?
Try overriding the onConfigurationChanged
method.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}