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.
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.
If you subclass the AdMob activity, then you can override its onBackPressed method to do nothing.
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
Related
I'm considering replacing regular ads with interstitials in our apps. I've got numerous emails from AdMob encouraging me to do this.
The problem is that our apps are live wallpapers so there's only one actual activity in them - live wallpaper settings. I can't think of any good implementation of interstitials periodic appearance.
According to guidelines, this type of ads must be shown between some interactions, like navigating from one activity to another.
I can show fullscreen ads every time after returning from live wallpaper settings activity to home screen, making sure user haven't seen interstitial like 3 min before (so users don't see them too often, because they can go to settings quite often).
It is possible to use AdMob interstitial ads in such scenario or not?
I can show fullscreen ads every time after returning from live
wallpaper settings activity to home screen, making sure user haven't
seen interstitial like 3 min before (so users don't see them too
often, because they can go to settings quite often).
This is good, can be implemented...
However, you can also use / show Interstitial Ads on App Exits...
For e.g. > User Presses Back > Load Interstitial > Ad Closed > Show App Exit Confirmation Dialog > User selects Exit > Call finish();
but if you do this -
User Presses Back > Load Interstitial > Ad Closed > Call finish() -- This is against policy...
When you are going to settings you should load the ad and whenever user click on some button check if the ad is loaded, if it is then show the ad and perform the action on ad closed, else perform the action.
You can also use shared preferences to keep record of user interaction. Set a specific limit and when shared preferences reaches that call for the ad load
I've an app that should always start from the initial activity when its icon on home screen is pressed.
I've managed to make this work in every situation by finishing the current activities when the application was going to be exited.
But there's a point in the app where this is not possible unless I ruin user experience a lot, which is if the user opens an ad offered by the app and then either goes to home screen (via home button for example) or press back button to keep on using the app.
In both cases the following events are fired: onAdLeftApplication-> onAdClosed-> on Resume (although as how I understand documentation onAdClosed shouldn't fire in the case of opening the browser, but well... it happens).
With this I find no way to differentiate between the 2 cases, although there might be an event, that would allow to differentiate them-
Think the easiest way to solve this problem is to always force that if the icon is pressed what is fired is never onResume, always onCreate, this way I don't have to worry about the app not starting from beginning for whatever, by default it's going to do that.
But maybe what I'm mentioning is not possible anyway, so maybe some event like the one I'm mentioning might help with this problem. I'll happily listen to any recomendation about that.
When the user starts the app, I'm able to retrieve a previously stored credential. When this happens, the blue SmartLock banner shows up. On the app I work on, this is covering a FAB making it unusable until the blue banner goes away. Is there a way to control the length of time the banner is shown? Additionally, is there a way to let the FAB move up like it would with a snackbar showing?
Lastly, if the user exits the app as the banner is showing, it will continue to show on the phone home screen, blocking any use of the bottom app bar. Is there a way to prevent this?
The auto sign-in banner is shown by Play Services and drawn over the app. The intent is to notify the user that their saved credentials have been retrieved and avoid app inadvertently not displaying or displaying the notification at an incongruous time or place.
Right now, there is not much flexibility about it, the banner won't be in the app view hierarchy and might cover other elements, such as floating action buttons, for a few seconds. In practice, we haven't found this to be much of an issue ... many apps have put the auto sign-in at start and it shows over a splash screen and only once per device install since most apps don't need to sign users out.
But fair concerns that if credentials might be retrieved frequently or user may interact or switch apps immediately after signing in. Do comment with any feedback/requests, examples of problematic scenarios, or suggestions of alternative UX or implementation we'll see if we can accommodate them.
When some users click an ad on my app and they are done viewing the ad, and want to come back to the app, if they hit the back button the control goes to the home screen but the app does not crash because they see it running in the background.
I am not overwriting the default behavior of the controls.
What could be causing this or is it the expected behavior ?
This is not expected behaviour.
If they are definitely pressing the back button (and not the home button), then it sounds like the intent that displayed the Play Store has been configured to start the Activity in a new Task. Unfortunately, there isn't anything you can do do about this except raise it with the ad network in question.
I have successfully added admob ads to my android app and can view test ads on the emulator and my development phone (Nexus One). When I click on one of the test ads, it opens the web browser or market to that particular page(gmail or whatever). I click the home button to exit, but when I try to start my app again, it takes me back to the market page or browser that came up when clicking the test ad.
I have a feeling it is something in the onLeaveApplication or onPresentScreen methods implemented with AdListener, but I'm lost and the adMob documentation doesn't provide much info on this.
Generally this is the expected behavior for an application. If you click home and then back on your application icon, most applications will jump back to the last activity on the stack. It's certainly possible to kill your application altogether and treat re-entry as a brand new instance of your application, but you probably don't want that either as all user state will be lost unless you explicitly save it, which is even more work.
The AdMob client SDK listener callbacks are all optional for you to implement; there's no expectation that you do anything in particular. They're there as a convenience for you to pause, save, or resume whatever activity you were doing before.
Users are generally used to hitting the back button to go back to your app, not home and then back into the app.