Android: Pressing ad causes Activity with locked orientation to change orientation
-
11-10-2019 - |
Question
All of the Activities in my app are locked into portrait orientation using:
android:screenOrientation="portrait"
I have ads showing at the top of a few of my Activities, and if I tilt the phone sideways and press the ad, it changes the underlying Activity into landscape orientation! I tried to override
onConfigurationChanged(Configuration newConfig)
by setting the configuration to portrait and calling through to super, but it has no effect. Any clue on how to fix this, or what's going on?
Solution
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Did the trick.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow