Alarm set in App with AlarmManager got removed when App Force Stop

元气小坏坏 提交于 2019-12-07 04:54:24
Lalit Poptani

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.

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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!