I have an Activity
which records videos from the front camera for the Activity
. The orientation is locked to Portrait in the AndroidManifest.xml
file via the following code:
<activity
android:name=".activity.SomeVideoActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="Video Activity"
android:screenOrientation="portrait" />
This works fine if the user enters the screen for the first time. However, after leaving this activity and coming back to it, apparently landscape mode is re-enabled.
I managed to salvage the situation by forcing the orientation at via the following codeblock:
@Override
protected void onResume() {
super.onResume();
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
So I am just curious as to why this happens only on just this one activity. I have checked other activities for onActivityResult
and they don't messed up the orientation settings at all.
UPDATE:
Actually this problem is solved by using this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
as my sole intention is to lock the activity to portrait and disable landscape rotation. I just want to understand why rotation is re-enabled in SomeVideoActivity
after it returns from another activity even though it is declared to have portrait orientation in AndroidManifest
.