我的應用程序在應用程序中顯示插頁式廣告,有時在應用程序因Internet速度較慢而關閉後顯示。在應用關閉後展示插頁式廣告違反了admob規則。如何阻止我的插頁式廣告在應用關閉後顯示廣告?如何停止應用退出後顯示的插頁式廣告?
public class des extends AppCompatActivity {
ImageButton imageView15;
InterstitialAd mInterstitialAd;
private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_des);
AdView mAdView = (AdView) findViewById(R.id.AdView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(des.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(getString(R.string.intertitial_id));
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
imageView15 = (ImageButton) findViewById(R.id.imageView15);
imageView15.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentLoadNewActivity = new Intent(des.this,vid.class);
startActivity(intentLoadNewActivity);
}
});
}
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}
您可以編輯我的Java代碼與任何的onDestroy服務類(),因爲當我嘗試它不是工作摧毀字變成紅色,我不知道如何修復它我trired ALT +進入即時通訊新的應用程序開發 –
您需要重寫onDestroy()方法快捷鍵(Ctrl + O) –
嘗試運行沒有如果塊只是銷燬方法 –