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
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)
//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);
On new Api Version AdRequest()
constuctor is private; you have to use
AdRequest.Builder
class:
mAdView.loadAd(new AdRequest.Builder().build())
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
With the new SDK now it is:
AdView.loadAd(new AdRequest());
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