How to schedule notifications using WorkManager?

Solution 1:

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.

Solution 2:

You can show notification with the help of workmanager. Workmanger can be used for scheduling single occurrence task or periodic occurrence task as well as we can schedule task at a particular time.

OneTimeWorkRequest request= new OneTimeWorkRequest.Builder(CustomWorkerClass.class)
.setInitialDelay(delayedTime, TimeUnit.MILLISECONDS)
.addTag("TAG")
.build();

'delayedTime' -> calculate time when to trigger notification

for more implementation details click here. To read more regarding workmanager click here