Android插页式广告重复

时间:2014-10-04 07:57:14

标签: android admob interstitial

在我的应用中,我添加了非页内广告整页广告。它在大多数手机上工作正常,但当我在朋友Galaxy Note 1中查看时,插页式广告正在重复和重复。我不知道为什么它只在一部手机上发生..我检查了三个以上的其他移动电话包括三星Galaxy S2,S3等...但在那些电话没有问题,我也在模拟器中测试过。一旦我关闭广告就没有问题,它不会重复。问题在于这个特定的手机,如果有人知道原因请帮忙......这是记忆或某些事情的问题..

我正在提供以下代码。

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.tabpmnth_xm);

        // Create the interstitial.
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId("ca-app-pub-xxxxxxxxxxxx8x/x2xxxxxxxx");

        // Create ad request.
        AdRequest aadRequest = new AdRequest.Builder()
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
        .addTestDevice("xxxxxxxxxxxxxxxxxxxx")
        .build();

        // Begin loading your interstitial.
        interstitial.loadAd(aadRequest);


        interstitial.setAdListener(new AdListener(){
              public void onAdLoaded(){
                   displayInterstitial();
              }
    });




public void displayInterstitial() {
        if (interstitial.isLoaded()) {
          interstitial.show();
        }
      }

2 个答案:

答案 0 :(得分:1)

对不起Jocheved的重播。如果每个手机中都没有出现此问题,那么问题可能出在该用户的移动设置中。只需检查他/她是否在他/她之前。设置>开发人员选项>不要保持活动"选择与否。如果选中它,则应用程序将在用户离开当前活动后立即销毁每个活动。因此,当显示插页式广告时,当前活动通常会在onPause中。但它将被销毁,当用户关闭插页式广告并再次返回时,oncreate将会运行并显示广告。为避免这种情况,您可以通知用户检查是否选择了该选项..否则您可能需要找到其他解决方案并通过编程解决。感谢..

答案 1 :(得分:-2)

https://groups.google.com/forum/#!topic/google-admob-ads-sdk/i6zOe2Hy-xc

查看以上链接,Google admob工程师已解释了为什么会出现此问题。不需要在onAdLoaded()中包含displayInterstitial()。要么你想在一段时间后显示插页式广告,我自己使用onCountdownTimer()来实现这一点。对于例如在5秒后显示广告。

        new CountDownTimer(5000, 5) {
                        @Override
                        public void onTick(long millisUntilFinished) {

                        }

                        @Override
                        public void onFinish() {
                                 displayInterstitial();
                        }
                    }.start();
相关问题