Android — How to properly handle onPause/onResume methods?

为君一笑 提交于 2019-12-03 03:53:38

Have you considered switching to onStart() and onStop(), rather than onResume() and onPause()?

I was having the same problem (I had my music player resume/pause at onResume()/onPause()) and the best solution I found is to pause and resume my activity when it is on the foreground which you can get with public void onWindowFocusChanged (boolean hasFocus) callback.

Edit: This in an old and slightly incorrect answer - correct response is described in the Android Developers Blog: making android games that play nice

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