Admob Interstitial 方向在启动时锁定为初始设备方向 [英] Admob Interstitial orientation is locked to the initial device orientation on startup

查看:26
本文介绍了Admob Interstitial 方向在启动时锁定为初始设备方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在集成 Admob 插页式广告时遇到了问题.我的应用支持纵向和横向,因此我将清单设置为:

I'm having a problem integrating Admob interstitial ads. My app supports both portrait AND landscape orientation, and as such I have set the manifest to:

android:screenOrientation="fullSensor"

问题是 Admob 插页式广告似乎在启动时固定/锁定到设备的原始方向.例如.如果我以纵向启动应用程序,然后将设备旋转到横向,然后显示一个广告,然后它就会出现在它的侧面(纵向)...

The problem is that the Admob interstitial appears to be fixed/locked to the original orientation of the device on start up. E.g. if I start the app in portrait orientation, and then rotate the device to landscape, then show an ad, then it appears on its side (in portrait orientation)...

如何强制插页式广告重置为新的设备方向?

How can I force the interstitial to reset to the new device orientation?

我正在加载这样的广告:

I am loading the ad like this:

interstitialAd = new InterstitialAd(activity);
interstitialAd.setAdUnitId(Config.ADMOB_UNIT_ID);

AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .build();

interstitialAd.loadAd(adRequest);

然后像这样显示:

interstitialAd.show();

推荐答案

我解决了这个问题.最后,它归结为在方向改变时重新请求广告,重要的是,在 UI 线程中运行该请求.

I fixed this. In the end it came down to re-requesting the ad on orientation change, and importantly, running that request in the UI thread.

这篇关于Admob Interstitial 方向在启动时锁定为初始设备方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆