Android:按下广告会导致锁定方向的 Activity 改变方向

发布于 2024-10-08 08:38:34 字数 280 浏览 0 评论 0原文

我的应用程序中的所有活动都使用以下方式锁定为纵向:

android:screenOrientation="portrait"

我在一些活动的顶部显示广告,如果我向侧面倾斜手机并按下广告,它会将底层活动更改为横向!我尝试

onConfigurationChanged(Configuration newConfig)

通过将配置设置为纵向并调用超级来覆盖,但没有效果。有关如何解决此问题或发生了什么事的任何线索?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是我的挚爱i 2024-10-15 08:38:34
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

成功了。

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

        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

Did the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文