Pirate
Pirate

Reputation: 545

Prevent activity to be killed by Android OS

I am creating an application where there is an activity which contains a chronometer running. When user leaves that activity by pressing home button without stopping the timer then the user is notified in the status bar notification and it will notify the user every hour about the timer running and when user come back to the app from any means then the timer screen should appear with the elapsed time in chronometer.

It is working fine if the user comes back to the screen within 30 minutes. Because after 30 minutes android kills my activity from background and my application starts from beginning.

I want to stop android for killing my activity from background. Please help if any body has any idea...

Upvotes: 0

Views: 1714

Answers (1)

Jave
Jave

Reputation: 31846

You cannot and should not prevent the system from killing your Activity, what you can do is use an AlarmManager to wake/revive your Activity with a set interval.
If you save the starting time of your chronometer when it starts counting it should be fairly easy to let it resume later on.

Upvotes: 1

Related Questions