Android: Show Interstitial Ad after user pressed notification - android

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.

Related

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

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?

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.

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

Android: Determine the previously displayed external Activity

In my application, I used a library that displays ads in my app. When a user clicks on the ad, it launches the Browser app, and the onClick events are handled by the library itself.
I also have a placed code in onPause() and onStart() methods that detects whether any of my Activities are sent to background (user pressed Home) or switching between any of my Activities.
So if the app is either freshly opened (no instance is running) or re-opened from background, it will display a dialog box. If the user is only switching from any of my Activites, then the dialog box shouldn't be displayed.
Now the problem is that when the user clicks on an Ad, the Browser app gets loaded and would mean that my App has been sent to background, and so when the user closes the Browser, it will still display the dialog box when it shouldn't.
Is it even possible for my App to determine the previously displayed external Activity (ie. Browser) and not display the dialog box?
Or are there better approaches that I can follow in implementing such setup?
Thanks in advance.
I don't think that there is a way for your Activity to know, which was the previous activity. A simple work-around is to save the time the dialog was displayed and not displayed it again, before some time passes. You can decide on the exact time period based on your application's requirements.
This may be in fact better in some situations. If the user switches from the Browser to your application and it has been some time he has used your application, it will be appropriate to show the dialog again.
you can use onResume() method to specify the behaviour when your activity get back from the background.

Categories

Resources