我的应用会在应用中显示插页式广告,有时会在应用因网速慢而关闭后显示。在应用关闭后显示插页式广告违反了 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();
}
}
}
问题是您在 OnAdLoaded 中显示不建议的添加。这会导致不良行为并在用户执行其他工作时拦截。所以您应该在 Activity 开始时加载您的广告,然后您应该显示它在通过检查是否已加载用户不受影响的时候。 这样,在用户使用完您的应用后,您的广告将不会显示,您的问题将得到解决。
关于java - 如何在应用退出后停止显示插页式广告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42670489/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |