Android: orientation change in landscape mode [closed]
When orientation changes in landscape mode, start a new activity. After back to this activity when orientation in portrait mode in Android.
Yes this the default behavior of any activity. If you want to stop this you can
- Set the activity asandroid:configChanges="orientation"
Then Override the onConfigurationChanged like this
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
If you want to react to the changes refer this
Faster Screen Orientation Change,
Retaining an Object During a Configuration Change
In the Android Manifest file xml for your app place this code in there in the activity for the forms that you want. Each form will have its own activity and you can specify which ones that you want to have as landscape. Find the name for the activity listed ".name"
<activity android:name=".name"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
The real key to this is make sure you specify screenOrientation="landscape"
this overrides the auto rotate sensor and it will not work for that screen.
I think that you can set only one orientation in your app so that you cannot change orientation like written in this Q&A
精彩评论