I can perfectly manage orientation change programatically, by using setRequestedOrientation
in onCreate
.
Everything works really fine, until I plug a HDMI cable. After this, the tablet "wants" to be in landscape mode. So when I open an activity, it shows first in "landscape" and then right after it shows in "portrait", (because I'm calling setRequestedOrientation(variable_with_orientation_desired_by_the_user)
where variable=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
in onCreate
As you can "see", my app keeps rotating on every activity the user opens;
If I set the orientantion for activity in the manifest, this problem is partially gone, since the orientation in manifest is the same that the user has picked up. If they are different, the same behavior starts again.
I tried this, but with no success:
@Override
public void onCreate(final Bundle saved)
{
setRequestedOrientation(ScreenOrientation);
super.onCreate(icicle);
}
So, is there any way to tell to android what orientantion it must create my activity, before it does create it? (But it cannot be in manifest)
I solved it by setting screenOrientation to "behind" in manifest file:
android:screenOrientation="behind"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With