I have all activities in portrait mode except the one that I use to play a video that is always landscape. I found that on Android 8.1 every time I open the video activity a
from Narmi's answer:
When you will back to Activity A from Activity B and if you know the screen's orientation of the Activity A, so set the screen orientation into the ondestroy of Activity B.
you have to detect if activity is destroying from configuration change,
so add field isConfigurationChanged = false
, then on onSaveInstanceState
method turn it to true
and on onDestroy
method add this:
@Override protected void onDestroy() { if(!isConfigurationChanged) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onDestroy(); }