Catch when Android application went on background

前端 未结 1 1859
無奈伤痛
無奈伤痛 2021-01-17 14:21

I need help with Android. Here is problem I need to catch event when application went to background. (ex. home is pressed or any other action that push my app in backgound)

相关标签:
1条回答
  • 2021-01-17 14:50

    From your comment it sounds like you want to know when your program returns from the background, instead of when it goes to the background.

    You can use onResume for that. also, see the Activity Lifecycle. You can see the remark "activity comes to the foreground", which is what I gather from your comment the thing you want.

    Note: your activity will call onResume the first time the activity is started, so you might want to set a boolean in onPause to signal your app that it actually went to the background.

    0 讨论(0)
提交回复
热议问题