Admob: Interstitial Ads Showing Every Time
i'm finishing a video application and i'm displaying interstitial ads when leaving the video activity. I just want to show it once every X minutes, but it seems to be showing every
Solution 1:
Two options :
Interstitial ads show when I am leaving current Activity but only If I completed X minute on current Activity.
boolean isAdShow=false; @OverrideprotectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int minute=1; // X minute isAdShow=false; newCountDownTimer(minute*60000,1000) { @OverridepublicvoidonTick(long millisUntilFinished) { } @OverridepublicvoidonFinish() { isAdShow=true; } }.start(); } privatevoidShowAds() { if (interstitialAd.isLoaded() && isAdShow) { interstitialAd.show(); interstitialAd.setAdListener(newAdListener() { @OverridepublicvoidonAdClosed() { super.onAdClosed(); finish(); } }); }else{ super.onBackPressed(); } }
Don't wait for user to press back button and leave current Activity, just call
ShowAds()
fromonFinish()
method of Timer.
I'll recommend to use 1 one because it not violate AdMob Ad policy and user experience too.
EDIT
You can also use X times counter, like when X = 3
i.e After 3 times call of onCreate()
method make eligible to show Ad.
publicstaticint adCounter;
publicstaticfinalint TIME_COUNTER=3; //Should be always greater than zero@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adCounter++;
}
privatevoidShowAds() {
if (interstitialAd.isLoaded() && adCounter%TIME_COUNTER==0) {
interstitialAd.show();
interstitialAd.setAdListener(newAdListener() {
@OverridepublicvoidonAdClosed() {
super.onAdClosed();
finish();
}
});
}else{
super.onBackPressed();
}
}
Post a Comment for "Admob: Interstitial Ads Showing Every Time"