我有3个活动A,B和C,我在活动B中显示间隙广告。但问题是,如果我立即返回活动A,间隙会出现在活动A中。如果我立即转到下一个活动C,间隙会出现在活动C中。但我希望间隙只显示在活动B中。因此谷歌没有接受我的应用程序更新。
发布于 2018-09-13 18:58:34
试试这条路
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();
}
发布于 2018-09-13 19:05:15
https://stackoverflow.com/questions/52312103
复制相似问题