How to hide interstitial ads in Android - android

I am working with AdMob in Android, and I am using both interstitial and banner ads. I want to hide interstitial ads, but it seems that there is not any suitable methods for hiding it.
Please help if you have any solutions.
Thanks in advance.

Taking answer from here
this.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
As whenever you press on back button the interstitial ad is closed so firing the back button event will eventually close the interstitial ad. Rest depends on the requirement.
Note: This is not an official way of doing this. It is just and hack/workaround.
As this answer points
It is not possible to programmatically close an interstitial ad.
Hope this helps.

Related

Android studio Interstitial Ad always displayed

I'm using admob with android studio.
I made a simple test use:
From my mainactivity.java i launch an interstitial ad before going through to the mainactivity2.java.
When the Interstitial ad is dismissed, i close the mainactivity.java with a finish();
Request.
When i press the back button on my phone the Interstitial ad is showing again.
Can someone explain me why ? I mean the first activity is supposed to be closed, so this mean the ad create his own activity ?
Thanks for help.

W/Ads: It is not recommended to show an interstitial when app is not in foreground

Do you know this "W/Ads: It is not recommended to show an interstitial when app is not in foreground."
How can i prevent this Warning/Error , I'm trying to show an interstitial when app is on foreground but the device is lock,under security.
on some device i'm can display interstitial when the device is lock and on other device i'm block.
Any Ideas?
You try to show an interstitialAd while the Activity is not in foreground.
You have to check if your activity is in foreground. If so, show the ad.
For example implementing a lifecycle listener.
After resume check if ad is loaded and show it.
GGK

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?

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

Google Play Game Services disconnects when user clicks on ad banner

I'm developing an Android game with multiplayer using Google Play Game Services. The game is working well, but one thing... An ad banner is displayed while players are playing, and if the user clicks on it, then the browser opens, and "onStop" is executed on my activity, and Game Services disconnects the player :(
Is there any way to solve it? I would like players could see ads without disconnecting :(
Try to capture the onclick event, than pause the app, and forward the event to browser's call
Remove any code relevant to disconnecting from your onStop() method.
If #1 is already solved, then it seems to be an issue with the AD-SDK that you are using.
My game implements AdMob SDK and the client is not disconnected when clicking on an ad even though the browser opens.
Let me know if you want any other help.

Categories

Resources