how to know application is going to destroy/remove?

Posted by Bhavesh Jethani on Stack Overflow See other posts from Stack Overflow or by Bhavesh Jethani
Published on 2014-05-27T10:52:55Z Indexed on 2014/05/29 9:27 UTC
Read the original article Hit count: 276

My requirement is, i want to cancel my alarm manager or services when application going to destroy/closed.

if i am in activity A by clicking on button started activity B suddenly user is going to press home button. ---- if application is running in background then don't cancel service. but when he going to remove from recent list of application at that time cancel service.

Service/Alarm manager will work even when user has sent application in background by pressing home screen.

No of way application can destroy or removed.
1) by clicking back button multiple times if stack have multiple activities.
2) by pressing home button and then remove from recent list.

i am facing issue with (2)second option. in that when user press home button at that time service or alarm manager should be work. But when user will be going to remove application from recent list at that time i want to cancel service/alarm manager.


Second issue.
my service is called at fix interval of time. if i will write code on onCreate(), onDestroy() in each activity. then timer will start from beginning.

Is there any listners who talk me application is going to closed?

© Stack Overflow or respective owner

Related posts about android

Related posts about interface