Google Play Game Services - How to Not Leave Room onPause

天涯浪子 提交于 2019-12-19 04:12:42

问题


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.



来源:https://stackoverflow.com/questions/18678211/google-play-game-services-how-to-not-leave-room-onpause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!