How to keep user in the game room even if activity loses focus

倾然丶 夕夏残阳落幕 提交于 2019-12-06 16:58:55

问题


By default when the user closes screen player leaves the room and when it opens the screen back user logs back in. I am extending BaseGameActivity and I start quick game on onSignInSucceeded. I want to keep the user in game even if the screen is closed, received a call etc.

1 . How can I achieve the desired behaviour?

2 . Am I misconfiguring something?

3 . Is this because of the way GameHelper is written? should I reimplement it?


回答1:


Currently, you cannot keep the game running if the Activity loses focus. This restriction is deep down in the API, not in GameHelper. We may or may not change in the future, but for now there is no way to achieve that behavior. The recommendation is calling leaveRoom() on onStop() to ensure proper cleanup.




回答2:


I remove gamehelper.onstop() in BaseGameActivity.onstop(), and it works.



来源:https://stackoverflow.com/questions/19100169/how-to-keep-user-in-the-game-room-even-if-activity-loses-focus

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