How to schedule notifications using WorkManager?

Ankur Gupta picture Ankur Gupta · May 11, 2018 · Viewed 10.1k times · Source

I want to schedule a notification everytime the user add a note in the database for a specific time. While there are multiple ways to do it using AlarmManager, BroadcastReceiver etc. How can it be done using WorkManager?

Answer

ianhanniballake picture ianhanniballake · May 13, 2018

WorkManager isn't appropriate for work that needs to happen at a particular time.

You should use AlarmManager, and specifically AlarmManagerCompat.setExactAndAllowWhileIdle(), to get a callback at a specific time.