How to force Admob to refresh on Android

后端 未结 7 844
迷失自我
迷失自我 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-08 00:18

    declare adView in activity as data member , then create Timer Task as bellow in your constructor of the activity

    adView = (AdView) findViewById(R.id.adView);
            TimerTask tt = new TimerTask() {
    
                @Override
                public void run() {
                MainActivity.this.runOnUiThread(new Runnable() {
                    public void run() {
                        adView.loadAd(new AdRequest());
                    }
                });
    
            }
        };
    
        Timer t = new Timer();
        t.scheduleAtFixedRate(tt, 0, 1000 * 60);
    
    0 讨论(0)
提交回复
热议问题