Bhabani Shankar
Bhabani Shankar

Reputation: 1285

Forcing admob to refresh ad every second in Android

I have built an android app which has a fixed screen that will remain focused for more than a minute. Kind of a story in the page.

I have integrated Admob adrequest into the application. But it is the single ad that comes on load of the screen and remains till I quit.

Can I do something so that the Ad will change every 1 sec.

Upvotes: 4

Views: 5405

Answers (3)

Deepak Patil
Deepak Patil

Reputation: 3489

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);

Upvotes: 0

Zwiebel
Zwiebel

Reputation: 1615

I think too that the 1 sec, is very-very short time, for ad change, generate more data for the user (what csan be very annoying), but you know. :) You can set it on the admob's page, when you logged in. Choose your application, then Manage Settings. Here app settings. But it only allow at least 12 seconds, what confirms my thinking. And I think if you use what Anand said, you even won't got ads in every sec.

Hope it helps.

Upvotes: 4

Anand Sainath
Anand Sainath

Reputation: 1807

You can control the refresh frequency by using the admob account online or you can also set the refresh time in seconds using the API :

  AdView.loadAd(new AdRequest());

Even though a call to the API will ask admob server to fetch a new ad, but that doesn't guarantee that a new ad will be fetched. Moreover, 1 second seems to be too short a interval to be refreshing your ads. If I was a user of your app, I would rather un-install it. :) But yes, that's my personal take on it..

Upvotes: 7

Related Questions