简体   繁体   中英

Activity's onDestroy method is not being called after swiping from background

i have implemented activity's lifecycle callback methods, when i swipe the activity from the background. onDestroy method is not being called, i searched for the answers and i got one from one stating that

"Swiping the app from the task list basically means "kill this app right now" it's not given any time to perform an onDestroy . None of the lifecycle methods will be called"

But in my case, sometimes onDestroy method is being called and sometimes not, i am unable to understand this.

Thanks.

There is no guarantee that your onDestroy method will be called at all. You can call onDestroy by calling finish() on your activity. The system calls onDestroy only for saving space. You can take a look here: link . What is important for you to know is that you have to be totally sure that this method will be called before you put some code in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM