How to avoid destroying app when an AdMOb banner is clicked? - android

I am using AdMob banner adds in my game. When I click on the add, I want app to pause while the user is taken to the ad content.
What is happening is that the app is completely destroyed and onCreate is called when I go back to the app.
How to resolve this?

Related

AdMob interstitials in app with single activity

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

How to continue app after back is pressed on clicking admob ad?

I am making a fitness app. During the rest period of fixed time I am showing ads using AdMob. If a user clicks on the ad then the app opens up browser/playstore. When the user clicks on back the browser/playstore closes and the user comes back to my app. But my app doesn't realize this and remains frozen. The rest period does not reduce. Only on clicking the app, does the app know that it is active. Is there a way to tell the app to continue once back is pressed after an admob ad is clicked?
When your app loses focus everything is paused. Override onResume method in your activity to restart what ever appears to be paused as per their normal behavior or you have explicitly pauses in onPaused method.

Android: Show Interstitial Ad after user pressed notification

Currently in my application when user presses notification an Activity is shown, what I want to do is to add Google Interstitial Ad in between (after user pressed notification and before the activity is shown). The problem is that it may take time for the ad to load. What would be the best approach to implement this?
Preload the ad when application is started to reduce the ad loading time.
But generally there is no magic solution. If the add takes time to load, give it that time, show a progress bar while it is loading. And only after the user interacted with the add, move to next activity.

Blocking "Back" button to Close Interstitial Ad

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

Activity restarts after showing the Ad from Admob

I have an app which has an activity-A. I am showing an Interestial Ad from Admob in it. This is achieved using the Google play services. When there is a weak signal, when I clicked the home button in middle of the app, I could see the home screen. Now when I again clicked the app, the app freshly starts (instead of continuing from the place where i left) and when I close the app using the close button which actually calls the finish() statement and closes the app. But after closing the app the app continuous the activity from the first place where i have pressed the home button which Is very strange to me. Kindly help me to resolve this
This is not happening when I have full internet signal / no signal.

Categories

Resources