J
J
james1792018-02-21 15:52:01
Android
james179, 2018-02-21 15:52:01

Why does Alarm Manager stop working after force quitting the application?

I know that Alarm Manager stops working after a reboot. To do this, I did the steps that are written here: https://stackoverflow.com/questions/17673746/start...
Now everything works successfully after a reboot.
But suppose the user started the alarm and after a while forcibly stopped it, then started it again, then the Alarm Manager does not work anymore. I even tried rebooting, to no avail. How can I force the user to force stop the application, then launch it and all alarms will be restored?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Marken, 2018-02-21
@AlexMarken

Because you run the AlarmManager in the application thread. You need to create a separate service in which you will run the AlarmManager. The service must be bound to the BootReceiver in the manifest (so that it starts after the device is started) and in the OnCreate MainActivity method (checking if the service is inactive, start it).
Plenty of examples on google

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question