Android onStop/onDestroy - when might these be used?

后端 未结 3 894
萌比男神i
萌比男神i 2021-02-14 08:21

Looking at the Activity Life Cycle diagram, I notice that onPause() and onStop() can both lead to the \"process\" being killed. This would require

3条回答
  •  面向向阳花
    2021-02-14 08:31

    If I got your question right: It depends what you want to do with your application. Let's say you are programming application that uses GPS. In the onStop() which is called when the activity is no longer visible to the user, you can remove these requests. Or you can stop the some service if your application is running any. Or you can save preferences (not recommended, do it in onPause() instead), or you can close permanent connection to a server.....If I think of anything else, I'll add more...

提交回复
热议问题