Android 如何正确显示插入式广告?
我有3个活动A、B和C,我在活动B中显示中间层ad。但问题是,如果我立即返回活动A,中间层出现在活动A中。如果我立即进入下一个活动C,间隙显示在活动C中。但我希望间隙仅显示在活动B中。基于此原因,谷歌尚未接受我的应用程序更新。请尝试这种方式Android 如何正确显示插入式广告?,android,interstitial,Android,Interstitial,我有3个活动A、B和C,我在活动B中显示中间层ad。但问题是,如果我立即返回活动A,中间层出现在活动A中。如果我立即进入下一个活动C,间隙显示在活动C中。但我希望间隙仅显示在活动B中。基于此原因,谷歌尚未接受我的应用程序更新。请尝试这种方式 InterstitialAd mInterstitial = new InterstitialAd(this); mInterstitial.setAdUnitId(getResources().getString(Your_
InterstitialAd mInterstitial = new InterstitialAd(this);
mInterstitial.setAdUnitId(getResources().getString(Your_init_id));
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitial.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Log.d("==","onAdLoaded");
mInterstitial.show();
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Log.d("==","onAdFailedToLoad"+errorCode);
moveToOtherActivity();
}
@Override
public void onAdOpened() {
// Code to be executed when the ad is displayed.
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
}
@Override
public void onAdClosed() {
// Code to be executed when when the interstitial ad is closed.
Log.d("==","onAdClosed");
moveToOtherActivity();
}
});
mInterstitial.loadAd(adRequest);
}
private void moveToOtherActivity() {
Intent intent;
intent = new Intent(this,Activity_which_you_want_to_display_after_interstitial .class);
startActivity(intent);
finish();
}
有一种方法可以隐藏中讨论的间隙 这并不能阻止它出现,它只是关闭了它 希望能有帮助