Blocking "Back" button to Close Interstitial Ad

Ivan Batalov picture Ivan Batalov · Oct 29, 2014 · Viewed 7.8k times · Source

I am adding interstitial ads to my android app using AdMob. I am wondering if there is a way to prevent users from closing them via pressing the "back" button (so they'd have to press the "x" button on the ad).

I know that AdMob is loading the ad in another activity, so I can't use my activity's onKeyDown() to do that.

Also, I am not sure if it's considered a good practice and if it's worth doing at all.

Thank you!

Update:

It appears that there is no easy way to override the back button in the ad's activity (since I don't have access to that activity). Thus, I'll give up on it.

However, I still haven't found any evidence that it is against admob or android policy. In most of android games the back button is overridden to turn the pause mode on and off (as opposed to go further back and eventually exit) and everyone seems to be okay with it. Therefore, I am still open to hear about this aspect from the people that actually know the answer.

P.S.: to the people that say that it's such a horrible thing to block the back button: I agree that this would make it more annoying for users, but the very idea of interstitial ads is pretty annoying to begin with. Despite of that, it is the most commonly used type of ads these days (guess why - it's just more profitable).

Now, most of the time if you use the back button you can close the ad even before it is loaded on the screen (I'm talking about loading of the layout, not loading of the data from the ad provider). But the whole idea of having ads is to show them to people. So, I think it is reasonable to allow users to close the ad only after it is fully loaded to the screen and not before that. And people that are saying otherwise (but at the same time not having anything against the very concept of interstitial ads) are hypocritical.

Answer

Gilad Eshkoli picture Gilad Eshkoli · Oct 29, 2014

Check Google/Android policy for overriding the Back button while publishing your app. Obviously they don't like it either as you disable a main feature from user stand-point.

But if you really need to avoid pressing the back button just override onBackPressed(), you can leave this function blanked.