1
我正在编辑现有android应用程序(不是游戏)的代码。我想在显示一定数量的屏幕或操作后显示插页式广告(请遵守Google指南)。如何在x操作后加载插页式广告
这是怎么了,我通常加载我的插页广告:
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(News_Detail.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(getString(R.string.admob_interstitial_id));
AdRequest adRequest = new AdRequest.Builder().build();
// Load ads into Interstitial Ads
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//Your code to show add
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}, 20000);
}
谢谢,但变量x它不会改变他的价值,如果我把这个功能就这样! –
x ++是一样的x = x + 1 –
是的,它增加它,我在哪里必须把这个代码? –