Reputation: 370
I want to show an interstitial ad during user presses back/home or recent app button. As all action goes via onStop() method, so i did call the ad like this
@Override
protected void onStop() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// do nothing
}
});
}else{
super.onStop();
}
}
But I am getting exception `E/AndroidRuntime(26313): Caused by: android.app.SuperNotCalledException: Activity {package.name...} did not call through to super.onStop()
Intention is during those pressing button, if ad is loaded then show, else call super to proceed. What I am doing wrong ? Any other approach ?
Upvotes: 0
Views: 71
Reputation: 1215
You need to call super.onStop
in all cases. Change your code as below
@Override
protected void onStop () {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// do nothing
}
});
}
super.onStop();
}
Upvotes: 1