Google Play Game Services - How to Not Leave Room

2020-03-07 06:05发布

问题:

I'm not sure why "https://stackoverflow.com/questions/18142763/is-it-possible-to-show-full-screen-activity-without-leaving-room-using-google-re" was closed as "off topic" as I have the same question.

If I switch to text messaging, someone calls, etc, then onPause() and potentially onStop() will be called. I presume those are what forces one to leave the room in a multiplayer game. I would rather the game not be ruined by these events though. Is it possible to somehow stay in the room while sending someone a quick text message or answering a phone call? Must I create a background service or something?

回答1:

Short answer: No.

Long answer: It's not possible because of the way the API is designed. Bruno has explained that several times. If the API were designed to allow you to retain state, sure. But Google made the decision not to go in that direction.

I don't see that the question is off topic, but you ARE asking for something counter to the API. That's just the way it works, and there's not much use asking why it's not possible.



回答2:

I have edited BaseGameActivity.onStop() and have removed gamehelper.onStop(). So I stop gamesclient only in onDestroy. My game work perfectly also in background now.