How to schedule notifications using WorkManager?

前端 未结 4 1115
一个人的身影
一个人的身影 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:28

    According to the Android official documentation about worker manager: "These APIs let you create a task and hand it off to WorkManager to run immediately or at an appropriate time". In my app, I set a work to be activated 20 seconds after:

     // Schedule the time
     val request= OneTimeWorkRequestBuilder().setInitialDelay(20, TimeUnit.SECONDS).build()
        WorkManager.getInstance().enqueue(request)
    

提交回复
热议问题