Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admob Interstitial orientation is locked to the initial device orientation on startup

Tags:

android

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"

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);

and then showing it like this:

interstitialAd.show();
like image 819
magritte Avatar asked Nov 12 '16 19:11

magritte


1 Answers

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.

like image 67
magritte Avatar answered Oct 19 '22 12:10

magritte