Daily notification at a given time

from the CommonsWare Community archives

At April 29, 2018, 3:28pm, Shahood asked:

I want to learn how to fire a notification at a given time on a daily basis, kind of a reminder, that takes you to an activity in the app for some data entry. The app is ready; i just need to implement notifications.
Which trails do I need to learn in addition to core chapters in order to implement that?
I’m guessing I need to go through:

Pl guide me in the right direction!


At April 29, 2018, 3:43pm, mmurphy replied:

I want to learn how to fire a notification at a given time on a daily basis

Android does not really support doing anything at a given time on a daily basis anymore, as of Android 6.0 and the introduction of Doze mode. Too many developers abused the privilege, to the detriment of users’ battery.

The closest that you will get is AlarmManager and setExactAndAllowWhileIdle(), but that might be off by ~10 minutes, and you may not have Internet access when the event occurs.

I’m guessing I need to go through

From your description, that should be sufficient. Depending on the notification itself, you may not need the “Advanced Notifications” chapter.


At April 29, 2018, 4:33pm, Shahood replied:

How do we still see recurring reminder notifications in many apps then? One example is Google Keep.


At April 29, 2018, 4:49pm, mmurphy replied:

Alarm clock apps can use setAlarmClock() on AlarmManager. Apps with a server component might use FCM to push events down to the apps. Apps that the user has added to the battery optimization whitelist can use AlarmManager normally without issue. Anything else is intrinsically inexact.

Also, do not draw conclusions based on what Google’s apps do. Google has the ability to cheat, in ways that ordinary developers do not.


At May 4, 2018, 3:23am, Shahood replied:

Does Android allow a daily reminder at least, if not daily at a given time?

And Google’s Keep was just one example. There are other apps too.


At May 4, 2018, 10:49am, mmurphy replied:

Does Android allow a daily reminder at least, if not daily at a given time?

For inexact events, you are welcome to use AlarmManager and JobScheduler.


At May 4, 2018, 11:24am, Shahood replied:

Great…thanks.