Search code examples
androidmultiplayergoogle-play-games

Android TurnBasedMultiplayer - How to get match updates when the screen is off?


I'm using the Google Play TurnBasedMultiplayer API for a turn based card game. I noticed that when a device is in an active match (game is running) and the screen is off, it will never receive match updates, even after turning the screen back on. So I'm left with a stale match when the screen is off and another player takes a turn.

I've registered a match update listener which works fine when the screen is on: Games.TurnBasedMultiplayer.registerMatchUpdateListener(getApiClient(), this);

But how am I supposed to handle the case where the screen is off and a match gets updated? Am I supposed to reload the match every time onSignInSucceeded gets called? I couldn't find anything in the Google documentation that mentioned this case.


Solution

  • If you look at the source code of BaseGameActivity the Google Api Client gets disconnected in onStop. So I'm guessing you aren't getting the notifications because the api client is disconnected. I'm loading/refreshing the matches each time the onSignInSucceeded gets called and it seems to be working as expected.