I recently added an interstitial ad using Admob with the Google Play services library (which is still pretty buggy BTW).
The interstitial is working well but the following call:
// Begin loading interstitial
interstitial.loadAd(adInterstitialRequest);
is very slow, it can delay up to 2 seconds the first launch of my app.
What could I do to avoid this? I followed exactly the example provided by Google here.
FYI I tried to load the ad in the background using an AsyncTask
but it does not seem possible to do it:
03-23 15:50:21.939: E/AndroidRuntime(3572): Caused by: java.lang.IllegalStateException: loadAd must be called on the main UI thread.
Thank you
Are you using the ad listener? try this:
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(Your-ad-id-here);
// Create ad request.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
// Begin loading your interstitial.
interstitial.loadAd(adRequest);
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
displayInterstitial();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With