I'm implementing interstitial banners on this Android app and wish them to appear when user finish()es the app through back button. It's already working fine when using solo AdMob interstitial by AdMob mediation, this way:
@Override
public void finish() {
if (isBannerAllowed() && InterstitialBannerFactory.getInsterstitialSingleton().isReady()) {
InterstitialBannerFactory.getInsterstitialSingleton().show();
}
finish();
}
It shows the AdMob banner and when user dismisses, it will finish the app the expected way.
BUT, when I include an InMobi interstital banner on mediation, it shows the banner but instantly finishes the app (strictly the remaining last activity of the app), without giving chance to user view the banner. It appears and suddenly finishes.
I know it happens because in some way that finish() on the end doesn't work fine with InMobi interstitial. I already tried to do something like this:
@Override
public void finish() {
setAppFinishing(true);
if (isBannerAllowed() && InterstitialBannerFactory.getInsterstitialSingleton().isReady()) {
InterstitialBannerFactory.getInsterstitialSingleton().show();
}
}
Note the setAppFinishing(true) at the begining and the removal of the finish() at the end.
It gets a little better, since it shows the InMobi interstitial. But prevents the user from exiting the app through back button.
Then I tried this on AdListerner's onDismissScreen() to complement above code:
@Override
public void onDismissScreen(Ad ad) {
// prepares the next
if (!isAppFinishing()) {
InterstitialBannerFactory.loadAd();
}
else {
finish();
}
}
But it doesn't take effect, the behaviour is the same and app is not exiting.
Does anyone have a smarter solution?
BTW, i'm using latest versions of all libs involved.
Regards.
InMobi's interstitial is displayed on the same activity whereas AdMob's interstitial looks like its opening in a new activity.
To solve this, you could override the back button in your app.More details found at - Override back button to act like home button
Example -
Note: onCreate creates a new Interstitial Object and calls a load on it. Code to finally finish the app when interstitial is closed:
-Akshay, SDK Developer, InMobi