@Override
public void onBackPressed(){
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(getApplicationContext());
// Insert the Ad Unit ID
interstitial.setAdUnitId("Your_add_unit_id_here");
// Request for Ads
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//.addTestDevice("CC5F2C72DF2B356BBF0DA198")
.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();
}
});
super.onBackPressed();
}
1 回答
对于问题没有 . 2,你需要覆盖onDestroy()或onBackPressed()来显示广告 . 代码示例:
使用后退按钮关闭活动后,它会显示插页式广告