Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have reproduced this issue with 100% reproducibility. Look for workaround below.</p> <p><strong>Description:</strong><br/> Admob interstitial is shown incorrectly on Android</p> <p><strong>Steps to reproduce:</strong></p> <p><ol> <li>Download admob interstitial sample using link "Download the example project" on page: <a href="https://developers.google.com/mobile-ads-sdk/docs/admob/advanced" rel="nofollow"><a href="https://developers.google.com/mobile-ads-sdk/docs/admob/advanced" rel="nofollow">https://developers.google.com/mobile-ads-sdk/docs/admob/advanced</a></a></li> <li>Open InterstitialSample.java</li> <li>Find in onCreate method the following 2 lines of code:<br/></p> <blockquote> <p>interstitialAd = new InterstitialAd(this, AD_UNIT_ID_GOES_HERE);<br/> interstitialAd.setAdListener(this);<br/></li> <li>Remove these 2 lines from onCreate method and add them to onClick before interstitialAd.loadAd(adRequest);</li> <li>Replace AD_UNIT_ID_GOES_HERE by your id</li> <li>Add GoogleAdMobAdsSdk-6.3.0.jar to project</li> <li>Build and run</li> <li>Click "Load Interstitial" button then "Show Interstitial" button</li> </ol> <strong>Observed result:</strong><br/> When device is in portrait orientation an interstitial shows landscape version of ad content, and vice versa when device is in landscape orientation an interstitial shows portrait version of ad content.</p> </blockquote> <p><strong>Configuration used for testing:</strong><br/> Android OS: 4.2.1 or 4.2.2<br/> GoogleAdMobAdsSdk: 6.2.1 or 6.3.0<br/> Device: Galaxy Nexus<br/></p> <h1> </h1> <p><strong>Workaround:</strong><br/> As you can see original sample without modification (when creation of InterstitialAd is done in Activity.onCreate) works properly. So main idea for workaround is to create the same conditions for showing interstitial inside your real application. If you couldn't place code for creating InterstitialAd object inside onCreate method of your real Activity or you need to show interstitial from arbitrary code (for example form inside library code) then you need to create additional "launcher" Activity. </p> <p>In my case I have used the following steps:<br/> 1. Create additional Activity (based on InterstitialSample from Google sample) which will be used as launcher for interstitial ad<br/> 2. Add code for creating InterstitialAd object and setting listener inside onCreate method of that Activity<br/> 3. Add code for loading interstitial ad to onCreate method<br/> 4. Add code for displaying interstitial ad to onReceiveAd listener method<br/> 5. Add code for finishing Activity to onFailedToReceiveAd and onDismissScreen listener methods<br/></p> <p>Then just launch this additional "launcher" Activity whenever you need to show ad. This workaround works for me. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload