How to reset alarm if app is force closed in android

The user force closes my app in the settings.

Yes, this clears alarms.

Some task killer app auto-killed my app process.

This does not clear alarms on any recent version of Android.

Android itself killed my app, because of the need of memory for front apps.

This does not clear alarms.

Please tell me how do I detect it?

Maintain a record of when your alarm last occurred (e.g., in SharedPreferences). When your code runs (e.g., LAUNCHER activity is started), check the last-alarm time. If it was a long time ago, you know that your alarms were cleared, and so you need to reschedule them.

rather how to set my alarms so that all these cases dont affect my alarms.

This is not possible. There are few cases where the alarms actually are cleared (reboots and Force Stop), and there is nothing you can do to prevent your alarms from being cleared in those cases.

Leave a Comment