11

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.

Ivan Batalov
  • 221
  • 3
  • 12
  • 4
    As an app user, I don't think I like you very much for trying to do that. (Also, what is motivating this?) – njzk2 Oct 29 '14 at 22:24
  • 2
    You'll probably get banned from admob for that – Nima Oct 29 '14 at 22:50
  • 1
    I want to do it because most of the time you can close the ad even before it's shown on the screen (during the time when the ad layout is being drawn) using the back button. So, the whole idea of the ad disappears. The last thing I want is to annoy users so much that they delete the app. However, I think that adding few ads with the blocked back button is better than adding a lot of ads without that button blocked. – Ivan Batalov Oct 30 '14 at 02:45
  • I'd like to do this too. Other ad networks' Interstitial Ads blocks the back button. Maybe we should switch instead. – Roger C S Wernersson Mar 20 '15 at 07:42
  • Have a look at Boardfeud for example. https://play.google.com/store/apps/details?id=com.woxbexter.boardfeud&hl=en – Roger C S Wernersson Mar 20 '15 at 07:55
  • Any update on this? We are facing the same issues. – mikemike396 Jan 03 '19 at 13:50

3 Answers3

1

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.

Gilad Eshkoli
  • 1,253
  • 11
  • 27
  • Here is the only thing I found: "Ads should not be placed on a "dead end" screen. There must be a way to exit any screen that contains an ad without having to click the ad (e.g., a "back" or "menu" button). Alternatively, users can be notified that the home button will exit the app." – Ivan Batalov Oct 30 '14 at 02:36
  • So, strictly speaking, it is not prohibited to block the back button as long as there is another way to close the ad. OnBackPressed wouldn't work since the ad is loaded in it's own activity and the InterstitialAd class is final – Ivan Batalov Oct 30 '14 at 02:38
0

If you subclass the AdMob activity, then you can override its onBackPressed method to do nothing.

akodiakson
  • 779
  • 1
  • 5
  • 10
0

This has recently been fixed by Google. If you update to SDK 19.3.0+ the back button will stop working when an interstitial ad is shown. You must now use the close or x button.

implementation 'com.google.android.gms:play-services-ads:19.6.0'

Source:

Can't dismiss Admob Interstitial Ads by pressing Back key button of Android device

Admob Interstitial ad is not closing when user presses back button on android 7,8,9 but works fine on android 10 and 6

mikemike396
  • 2,435
  • 1
  • 26
  • 41