Daily notification at a given time


#1

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:

  • Notifications
  • Advanced Notifications
  • AlarmManager

Pl guide me in the right direction!


#2

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.


#3

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


#4

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.


#5

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.


#6

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.


#7

Great…thanks.