直到屏幕被触摸的AdMob与PhoneGap的3.0履历显示空白页 [英] AdMob with PhoneGap 3.0 on resume displays blank page until screen is touched

查看:241
本文介绍了直到屏幕被触摸的AdMob与PhoneGap的3.0履历显示空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我犯了PhoneGap的使用3.0的应用程序,其中包括谷歌AdMob广告和Facebook的SDK。

有时,应用程序被中止后(由pressing家为例),当它再次推出的浏览器窗口是空白的(仍显示AdMob广告在屏幕的底部)。只要您在网络视图中触摸它正确地呈现页面。在Web视图的底部大约5个像素在任何时候都保持可见。

我试图让一个截图,包括在这里,但服用截图也导致页面正确呈现!

这听起来像与Android / HTC Sense的/驱动器等内部问题,当我在测试Android 4.3的应用程序上的HTC One出现问题。我也试图在2.3,我不能重现该问题。

有没有在LogCat中的信息有用的东西 - 这可能与唯一的事件是 MainScreen - 汇总更新,当我接触到的网络视图力发生它呈现的内容。

我的下一个步骤是创建一个空白PhoneGap的应用程序来看看我是否能复制它,增加功能(脸谱,AdMob的),有点在一个时间,直到它再次发生,试图查明原因。

没有任何人有类似问题的经验,或者你可以建议什么我可以试试吗?

更新

如果我删除$ C $载荷c中的AdMob广告,问题消失。这肯定是通过AdMob广告引起的。这是code我使用加载广告:

  mHandler.postDelayed(新的Runnable(){
        公共无效的run(){
            loadAd();
        }
    },2000);
    私人无效loadAd(){
        AD浏览=新的AdView(这一点,AdSize.BANNER,我-ID);
        的LinearLayout布局= super.root;
        layout.addView(AD浏览);
        layout.setHorizo​​ntalGravity(android.view.Gravity.CENTER_HORIZONTAL);
        adView.loadAd(新AdRequest中());
    }


解决方案

要解决此问题,我删除了AdView中,当应用程序被暂停,而当它恢复重新创建它。

  @覆盖
保护无效的onPause(){
  super.onPause();  如果(AD浏览!= NULL){
    的LinearLayout布局= super.root;
    layout.removeView(AD浏览);
  }
}

这工作得很好所以会做了。它还$ P $持续在后台加载广告,这样的奖金pvents AdView的。

如果任何人有任何更好的答案随时让我知道!

I've made an app using PhoneGap 3.0, which includes the Google AdMob and Facebook SDKs.

Sometimes, after the app is suspended (by pressing "home" for example), when it's launched again the browser viewport is blank (the AdMob ad at the bottom of the screen is still displayed). As soon as you touch inside the web view it renders the page correctly. Around 5 pixels at the bottom of the web view remain visible at all times.

I tried to get a screenshot to include here, but taking a screenshot also causes the page to be rendered correctly!

It sounds like an internal issue with Android/HTC Sense/drivers etc. The problem occurs when I test the app in Android 4.3 on an HTC One. I've also tried it on 2.3 and I can't reproduce the issue.

There isn't anything useful in the LogCat messages - the only event that might be related is MainScreen - Summary updated, which occurs when I touch the web view to force it to render the contents.

My next steps are to create a blank PhoneGap app to see if I can reproduce it, adding functionality (Facebook, AdMob) a bit at a time until it happens again to try and pinpoint the cause.

Does anyone have any experience of a similar issue, or could you suggest anything I can try?

UPDATE

If I remove the code the loads the AdMob ad, the problem goes away. This is definitely caused by AdMob. This is the code I'm using to load the Ad:

    mHandler.postDelayed(new Runnable() {
        public void run() {
            loadAd();
        }
    }, 2000); 


    private void loadAd() {
        adView = new AdView(this, AdSize.BANNER, "my-id");
        LinearLayout layout = super.root;
        layout.addView(adView);
        layout.setHorizontalGravity(android.view.Gravity.CENTER_HORIZONTAL);
        adView.loadAd(new AdRequest());
    }

解决方案

To work around the problem I remove the AdView when the app is paused, and create it again when it's resumed.

@Override
protected void onPause() {
  super.onPause();

  if (adView != null) {
    LinearLayout layout = super.root;
    layout.removeView(adView);
  }
}

This works fine so will do for now. It also prevents the AdView from continuing to load ads in the background so that's a bonus.

If anyone has any better answers feel free to let me know!

这篇关于直到屏幕被触摸的AdMob与PhoneGap的3.0履历显示空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆