When an app sets a repeating alarm and from the users point of view the phone is in normal mode with an alarm in the notification bar what is happening with the code of the app? I assume the values of all the variables are stored in the phone memory in such a way that when the alarm wakes up the original state is restored. Does setting an alarm impose much more demand on the battery?
Share
AlarmManagerhas nothing to do with the AlarmClock application. There is no “alarm in the notification bar” unless you put something there yourself, which would be a bit unusual for an app employingAlarmManager.Assuming you are referring to
AlarmManager, “what is happening with the code of the app” is it better be shut down. The point behindAlarmManageris so you do not have to keep any code in memory just to watch the clock tick by.That is absolutely incorrect.
AlarmManagerdoes nothing of the sort. And, a well-written app usingAlarmManagerwill get the heck out of memory when it is not delivering any immediate value. If you need data to persist between alarms, use databases or files.A
_WAKEUPalarm will have an impact on the battery proportional to the frequency with which the alarm goes off. If the alarm is nice and infrequent (e.g., user configured to every 15 minutes), the alarm itself will have little impact, but what you do when the alarm goes off might.