1

I am trying to create an alarm using AlarmManager it works fine even when device is locked.

But when I kill the application using Settings -> Manege App -> MyApp -> Force Stop then my alarm destroys all the settings.

So please tell me how to save my alarm settings after application is killed even by forced stop and it notifies me on its usual time.

Thanks in advance...

2 Answers 2

3

As of Android 3.1, if a user force closes your application, all alarms will be cancelled and will need to be rescheduled from within your code...

From Android Docs.... Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications. A background service or application can override this behavior by adding the FLAG_INCLUDE_STOPPED_PACKAGES flag to broadcast intents that should be allowed to activate stopped applications.

Applications are in a stopped state when they are first installed but are not yet launched and when they are manually stopped by the user (in Manage Applications).

2

But when I kill the application using Settings -> Manege App -> MyApp -> Force Stop then my alarm destroys all the settings.

AlaramManager is critical system service that runs all the time. And if your application scheduled something and was killed, then AlarmManager may start application again (via PendingIntent).

Just Check this Answer on StackOverflow.

2
  • Thanks for quick reply Lalit.. but can u please give me a sample of code how it is done because i already use PendingIntent but it doesn't work fine.. :( Jun 29, 2012 at 5:10
  • There are many examples already available on web, please google it. Jun 29, 2012 at 8:33

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.