开发者

Android: Pressing ad causes Activity with locked orientation to change orientation

开发者 https://www.devze.com 2023-01-31 00:19 出处:网络
All of the Activities in my app are locked into portrait orientation using: android:screenOrientation=\"portrait\"

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 se开发者_Python百科tting 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?


    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

Did the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消