AdMob won't show the banner until refresh or sign in to google plus

后端 未结 5 1868
别那么骄傲
别那么骄傲 2020-12-28 18:50

I\'ve got a problem. My AdMob has been set up for some time now without any problem, but I noticed something wrong. Ad gets successfully loaded (i see message from ddms), bu

相关标签:
5条回答
  • 2020-12-28 19:33

    The above solution works. Even a simpler way to keep the banner shown is to set its background.

    adMobView.setBackgroundColor(Color.BLACK);
    
    0 讨论(0)
  • 2020-12-28 19:39
    banner.setBackgroundColor(Color.TRANSPARENT);
    

    This seems to fix the issue for me. Also be sure to run the banner creation code from within the UI thread.

    activity.runOnUiThread(new Runnable()
    {
        @Override
        public void run()
        {
            // all your banner creation code is here
            banner.setBackgroundColor(Color.TRANSPARENT);
        }
    });
    
    0 讨论(0)
  • 2020-12-28 19:47

    As nobody has replied with explanation, I'm going to consider this one solved. I just manually reload whole layout onAdLoad event. Anyway, this is just functional solution, it does not explain why it happens with Google Play Services AdMob.

    adMobView.setAdListener(new AdListener() {
    
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
    
            MainActivity.this.runOnUiThread(new Runnable() {
    
                @Override
                public void run() {
                    layout.requestLayout();
                }
            });
        }
    
    });
    

    Also, as mentioned by user3263204, you can try this

    adMobView.setBackgroundColor(Color.BLACK);
    

    to solve your problem.

    0 讨论(0)
  • 2020-12-28 19:48

    As user3263204 says, you can use setBackgroundColor to make the adview appear. You can make the background transparent, if (as in my case) you have the adview over something else:

    adMobView.setBackgroundColor(getResources().getColor(android.R.color.transparent));

    0 讨论(0)
  • 2020-12-28 19:52

    You can also requestWindowFeature(Window.FEATURE_NO_TITLE); and set to full screen and the ads shows.

    0 讨论(0)
提交回复
热议问题