【发布时间】:2018-03-05 01:55:08
【问题描述】:
我在我的应用程序中集成了 AdMob 制作 android 应用程序,我正在使用 AdMob 在 WebView 加载 20 秒后显示广告。问题是当用户在 20 秒前关闭应用时,仍然显示插页式广告,这违反了 google AdMob 政策,我怎样才能让用户退出活动或应用时,插页式广告不应该显示
这是我的代码:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
interAd = new InterstitialAd(MainActivity.this);
interAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID")
.build();
interAd.loadAd(adRequest);
interAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
interAd.show();
}
});
interAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// Code to be executed when the interstitial ad is closed.
Log.i("Ads", "onAdClosed");
}
});
}
} , 20000);
【问题讨论】:
标签: android android-studio firebase admob interstitial