1
私は既存のAndroidアプリケーション(ゲームではない)のコードを編集しています。一定の数の画面や操作が行われた後にインタースティシャル広告を表示したい(Googleガイダンスを尊重する)。xアクション後にインタースティシャル広告を読み込む方法
これは私が通常私のインタースティシャル広告をロードする方法である:あなたが示さなければならない場合は、それをインクリメントする方法、およびチェックを行い、int
を使用して、アクションを追跡
// 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と同じです –
はい、それをインクリメントします。このコードはどこに置く必要がありますか? –