I know I can use isFinishing() in onPause() to know whether an activity is going to be killed by finish().
Then, how can I know an activity is going to be killed by OS temporarily due to low memory?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Per the docs,
onDestroyshould be called right before the Activity is destroyed, regardless of the reason. If the finish was requested,isFinishingwill return true. So if it is false, you can assume that the system needed to finish.However, as the docs also say
In general, you cannot guarantee that your Activity will be killed nicely. Things like task killers mess with the lifecycle.
Use
onPauseoronSaveInstanceStateto save things properly.