如何使用WorkManager安排通知? [英] How to schedule notifications using WorkManager?

查看:190
本文介绍了如何使用WorkManager安排通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户每次在数据库中添加注释达特定时间时安排通知.尽管有多种方法可以使用AlarmManager,BroadcastReceiver等来实现.如何使用WorkManager来实现?

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?

推荐答案

WorkManager不适合需要在特定时间进行的工作.

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

您应该使用AlarmManager,尤其是

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

这篇关于如何使用WorkManager安排通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆