开发者

Android onAppHasFocus onAppLosesFocus

Thanks in adv开发者_Python百科ance for your help with this question

I want to know when my app gains and loses focus.

I know how to tell when a specific activity window gains or loses focus, but if the main activity window has sub windows that open, the main window loses focus

I want to know when my app loses focus entirely, including it's sub activities, and gains focus after it was entirely out of focus

thanks


Check

onPause

and

onResume


  1. Extend the Application
  2. Create for each activity a boolean inside
  3. onPause() / onDestroy() of each activity sets its boolean to false and calls the Application's checkIfAllDead()

checkIfAllDead() checks if all the booleans are false...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜