I am using Facebook Audience Network and according to this article
I am not caching ads but ads stays on screen without refreshing. I am loading all ads at once and they stay on screen until user closes the app.
private void initializeAds() {
//ENABLE TESTING MODE
if (BuildConfig.DEBUG) {
AdSettings.addTestDevice("alksdfj");//For testing ads
}
//NATIVE AD
nativeAd = new NativeAd(this, "alksdjf");
nativeAd.setAdListener(new AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
}
@Override
public void onAdLoaded(Ad ad) {
// Render the Native Ad Template
View adView = NativeAdView.render(MainActivity.this, nativeAd, NativeAdView.Type.HEIGHT_120);
LinearLayout nativeAdContainer = (LinearLayout) findViewById(R.id.native_ad_container);
// Add the Native Ad View to your ad container
nativeAdContainer.addView(adView);
}
@Override
public void onAdClicked(Ad ad) {
}
@Override
public void onLoggingImpression(Ad ad) {
}
});
//BANNER AD
// Instantiate an AdView view
adView = new AdView(this, "alksdjf", AdSize.BANNER_HEIGHT_50);
// Find the Ad Container
LinearLayout adContainer = (LinearLayout) findViewById(R.id.banner_container);
// Add the ad view to your activity layout
adContainer.addView(adView);
//Interstitial AD
interstitialAd = new InterstitialAd(this, "alskdfj");
// Set listeners for the Interstitial Ad
interstitialAd.setAdListener(new InterstitialAdListener() {
@Override
public void onInterstitialDisplayed(Ad ad) {
// Interstitial displayed callback
}
@Override
public void onInterstitialDismissed(Ad ad) {
// Interstitial dismissed callback
}
@Override
public void onError(Ad ad, AdError adError) {
// Ad error callback
/*Toast.makeText(MainActivity.this, "Error: " + adError.getErrorMessage(),
Toast.LENGTH_LONG).show();*/
Log.d("FACEBOOK_ADS", adError.getErrorMessage());
}
@Override
public void onAdLoaded(Ad ad) {
// Show the ad when it's done loading.
}
@Override
public void onAdClicked(Ad ad) {
// Ad clicked callback
}
@Override
public void onLoggingImpression(Ad ad) {
// Ad impression logged callback
}
});
// Request an ad
nativeAd.loadAd();
adView.loadAd();
// For auto play video ads, it's recommended to load the ad
// at least 30 seconds before it is shown
interstitialAd.loadAd();
//interstitialAd.show();
}
These ads can stay for long hours there. Also i am using interstitial ad that's loaded but only show to user when user unlock their device. (User can take hours to unlock their device)
I want in this scenario will theses ads generate revenue or do i need to re-request ads after some time like with cached ads.
Also BannerAds has refresh interval settings. Will that automatically refresh ads or do i need to refresh them as well