How to force Admob to refresh on Android

后端 未结 7 843
迷失自我
迷失自我 2021-01-07 23:30

I have an app with Admob ads on it but I find that when I use it the ad almost never refreshes because I don\'t change activities, instead I just update a text view when but

相关标签:
7条回答
  • 2021-01-07 23:56

    As an alternative you can also have Admob refresh ads for you at time intervals you specify. In Admob go to "Sites and Apps", then click "Manage Settings" for the app you want. Then click on "app settings". There under "Automatic refresh" you can change the refresh rate for ads in your app.

    EDIT: with the new admob interface it is under Monetize > My App Name > My Add Unit Name > Refresh Rate (thanks ripegooseberry)

    0 讨论(0)
  • 2021-01-08 00:04
        //New AdRequest 
    
        ScheduledExecutorService scheduleTaskExecutor = Executors.newScheduledThreadPool(5);
    
    
    scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() {
      public void run() {
            runOnUiThread(new Runnable() {
                public void run() {
                     AdRequest adRequest = new AdRequest.Builder().build();
                    adView.loadAd(adRequest);
                }
            });
        }
    
    }, 0, 30, TimeUnit.SECONDS);
    
    0 讨论(0)
  • 2021-01-08 00:08

    On new Api Version AdRequest() constuctor is private; you have to use AdRequest.Builder class:

    mAdView.loadAd(new AdRequest.Builder().build())
    
    0 讨论(0)
  • 2021-01-08 00:08
    private AdRequest adRequest = null;
    private void loadBannerRun() {
        if(adRequest != null) {
            adView.loadAd(adRequest);
            return;
        }
        adView.setAdUnitId(BANNER_AD_TEST);
        adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);
    }
    

    test please

    0 讨论(0)
  • 2021-01-08 00:17

    With the new SDK now it is:

    AdView.loadAd(new AdRequest());
    
    0 讨论(0)
  • 2021-01-08 00:17

    Old API version:

    AdView.requestFreshAd();
    

    New API version:

    AdView.loadAd(new AdRequest());
    

    Also, you can simply set a refresh interval with the refreshInterval attribute on the AdView element in your layout XML file. Or you can set the refresh interval for the ads in your app via your account settings on the AdMob website.

    Documentation: http://code.google.com/mobile/ads/docs/android/intermediate.html#adrefresh

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