Yoa*_*uet 7 android admob google-play-services
我最近使用Admob添加了一个插页式广告,其中包含Google Play服务库(这仍然是一个非常错误的BTW).
插页式广告运作良好,但以下电话:
// Begin loading interstitial
interstitial.loadAd(adInterstitialRequest);
Run Code Online (Sandbox Code Playgroud)
非常慢,它可以在我的应用程序首次启动时延迟最多2秒.
我该怎么做才能避免这种情况?我严格遵循谷歌提供的例子在这里.
仅供参考我尝试使用a在后台加载广告,AsyncTask但似乎无法做到:
03-23 15:50:21.939: E/AndroidRuntime(3572): Caused by: java.lang.IllegalStateException: loadAd must be called on the main UI thread.
Run Code Online (Sandbox Code Playgroud)
谢谢
您使用广告监听器吗?尝试这个:
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();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2948 次 |
| 最近记录: |