Is there a way to preload AdMob ads on Android?

后端 未结 3 1231
鱼传尺愫
鱼传尺愫 2021-01-19 02:13

I have a AdMob ad in a \"dialog\" (a View I created to look like one, because ads will not fit in a normal Dialog) in my app. Usually it takes about 4 or 5 seconds before th

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 02:24

    First in another persistent context, you create AdView of admob and load ad with AdRequest.

    And then, add the AdView in 'onCreateView' of DialogFragment. Make sure the AdView is removed from previous parent view.

    if (adView.getParent() != null) {
        ((ViewGroup) adView.getParent()).removeView(adView);
    }
    
    // Add the banner ad to the ad view.
    adCardView.addView(adView);
    

提交回复
热议问题