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.
Related
I am using AdMob's RewardedVideoAd.
What I've done is when user opens a chat activity, I ask him to view a video to be able to chat to another user (by simply switching visibility of the chat elements). Then, after the video is watched, I make the chat elements visible.
It works well on the emulator. However, when I tested it on my phone, the chat activity is closed after video is watched. I cannot understand why this is happening.
It only happens if a user watches the video till the end (onRewarded() is called).
Any suggestions?
Ok, I worked it out.
It happened, because I did not forward the lifecycle events. After I called resume(context), pause(c), destroy(c) according to my Activity lifecycle, it worked.
God knows why it worked fine on the emulator and did not on my phone.
The "Google Play Services" library contains an integrated fallback system in case of lost packets?
Here is the problem. I have a app that works like this:
The player A sends a reliable message to the player B
The player A can not send another message as long as the player B has not returned a callback via a reliable message.
If the callback takes too long or is negative, the game is disconnected.
Thereby I ensure that the game always remains synchronized.
The problem is that sometimes, when the connection is poor, the player B's game get suddenly a few steps back (usually 3 to 5).
The interesting thing is that this application has no methods to get back this way, and that it remains connected after this, although it's out of sync.
I have found nothing in the official documentation.
Did one of you already experienced this issue?
I am writing a multiplayer game and if I start the app from a desktop icon and another player takes a turn then the game updates correctly via the UpdateMatchResult callback. However, if I don't have the app open and get a notification that a turn has been taken by Google Play Games, then if I respond to that notification and use Google Play Games to take me to the match in my app, then if I take a turn and await an update after another player takes a turn, I continue to get notifications, even though I am actually in the app.
What could be causing this? Ideally, I'd like to see the update in the game, as I do when I go in via the normal icon.
This was a simple coding issue. I have solved this now.
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
I've integrated AdMob with my app. I can't seem to find this in any AdMob references.
Are AdMobs still running and bringing you revenue even if the app is in background or the ad is not visible? (for example
the user pressed the "Home" button
the user turned off the screen
the ad is positioned outside screen bounds
In my opinon this is clearly a wrong behavior if AdMob is still requesting ads and paying money per impressions in any of the above cases.
How does this actually work? Can anyone point me to a link/reference that exaplains this behavior?
Thanks
Clicking back, home, or closing your phone will pause your application but not terminate it. It is possible to run your application as a Service\WakeLock and it will continue to run in the background. Admob requests should not be running in the background if your application is paused. You should not be receiving impressions or revenue while your application is in the background.
Quote from AdMob: background requests?
You can see in LogCat when AdMob is requesting ad. Are you seeing any
requests when your app is in the foreground (you should), and when
your app pauses (you should not see any requests)?
By: Android Dev Guy