【问题标题】:Ads still show even after user left the application or close it即使在用户离开或关闭应用程序后,广告仍会显示
【发布时间】:2018-10-27 02:41:29
【问题描述】:

在我的应用程序关闭后,或者即使用户离开了违反 Admob 规则的应用程序,插页式广告仍然会显示。如何阻止这种情况,请注意我在将代码添加到我的应用程序时遵循了实施指南?

我使用抽屉式导航作为我实施插页式广告的主要活动。

    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-xxxxxxxxxxxxxxxxxxxx");
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            mInterstitialAd.show(); }

    });

【问题讨论】:

  • 专业提示:这里最好用真话。像“kinda”和“plz”这样的词往往会吸引反对票,因为它们可能会激怒一些读者。请尽可能坚持技术写作。
  • 很抱歉,我会避免添加任何缩写

标签: android admob interstitial


【解决方案1】:

创建一个 onPause() 方法。 ((系统调用此方法作为用户离开您的活动的第一个指示(尽管它并不总是意味着活动正在被销毁)))。

@Override
protected void onPause() {
    handler.removeCallbacks(your handler name here);
    interAd =null
    super.onPause();
}

其他:onCreate()、onStart()、onResume()、onPause()、onStop() 和 onDestroy()

更多信息在这里 --> https://developer.android.com/guide/components/activities/activity-lifecycle

【讨论】:

  • 我现在有点使用受保护的代码 void onPause() { if(mInterstitialAd != null){ mInterstitialAd.setAdListener(null); } super.onPause(); } 受保护的无效 onResume() { if (mInterstitialAd.isLoaded()) { mInterstitialAd.show(); } super.onResume();我会看看它是否有效..非常感谢您回答我的问题
猜你喜欢
  • 2018-03-05
  • 2019-08-01
  • 2021-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-02
相关资源
最近更新 更多