问题
Lately I am getting black screens when displaying Interstitial ads using admob. This is the screen I am talking about:
Some time it works well and displays an ad correctly. This is the code I use:
Class variable:
private InterstitialAd oInterstitialAd=null;
In the activity onCreate:
oInterstitialAd = new InterstitialAd(this);
oInterstitialAd.setAdUnitId(xxxxxxx);
oInterstitialAd.setAdListener(new AdListener()
{ @Override public void onAdLoaded()
{ oInterstitialAd.show();
finish();
}
@Override public void onAdFailedToLoad(int errorCode)
{ LogError("onAdFailedToLoad " + errorCode);
finish();
}
});
AdRequest oAdRequest = new AdRequest.Builder().build();
oInterstitialAd.loadAd(oAdRequest);
Thanks
回答1:
Wait for some time, it's loading. The network speed is slow
回答2:
Don't call interstitial.show() from the AdListener. This will generate a really poor user experience as the ad can show up in mid game etc.
You should instead call interstitial.show() from a natural break point in your app.
I also think it's highly unlikely that you want to be calling Activity.finish() from the AdListener methods.
You didn't mention what version of Admob you are using but it is not the current Google Play Services version. This may be causing your display problems.
回答3:
I am having the same issue.
Check by switching between devices and wifi networks. Mostly its the problem of your wifi which the google has added to the temporary blacklist.
If it works on other devices or other networks. It's not the issue with ads its problem with device or network.
来源:https://stackoverflow.com/questions/22891918/admob-insterstitial-display-a-black-screen