Lock back button to close interstitial

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 by clicking the back button (so that they click the x button in the ad).

I know AdMob is loading an ad into another action, so I cannot use my onKeyDown () activity to do this.

Also, I'm not sure if he considered good practice and whether it was worth doing at all.

Thanks!

Update:

There seems to be no easy way to override the back button in an ad’s activity (since I don’t have access to this activity). So I will give up on this.

However, I still have not found any evidence that this is against the admob or android policy. In most Android games, the back button is redefined to turn pause mode on and off (as opposed to moving on and finally quitting), and everything seems to be okay with it. Therefore, I am still ready to hear about this aspect from people who really know the answer.

PS: people who say it's such a terrible thing to block the back button: I agree that this will make it more annoying for users, but the idea of ​​interstitial ads is very unpleasant to start with. Despite this, these days it is the most common type of ad (I think for some reason it is 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 downloading the layout, not downloading data from the advertising provider). But the whole idea of ​​advertising is to show them to people. Therefore, I think it is reasonable to allow users to close the ad only after it has fully loaded onto the screen, and not before that. And people who say differently (but at the same time have nothing against the very concept of interstitial ads) are hypocritical.

+5
source share
2 answers

Check the Google / Android policy to override the back button when publishing the application. Obviously, they don’t like it, since you will disable the main function from the user's point of view.

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

+1
source

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

0
source

Source: https://habr.com/ru/post/1205816/


All Articles