How to schedule notifications using WorkManager?

前端 未结 4 1112
一个人的身影
一个人的身影 2020-11-29 08:24

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, BroadcastRece

4条回答
  •  独厮守ぢ
    2020-11-29 09:26

    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

提交回复
热议问题