[英]How can I run background work like alarm on latest android phones
I have some task like medicine reminder. 我有一些任务,例如提醒药物。 Everyday reminder schedule is stored in the SQLite database.
日常提醒计划存储在SQLite数据库中。 Reminders are every day different.
提醒每天都不同。
For example 例如
21.02.19 - 08:00, 12:00, 19:00 19.02.19-08:00,12:00,19:00
22.02.19 - 08:30, 12:30, 19:30 22.02.19-08:30,12:30,19:30
... ...
Minimum android 4.4 (Api 19) Target android 9.0 (Api 28) 最低android 4.4(Api 19)目标android 9.0(Api 28)
I read about WorkManager, JobScheduler, JobIntentService, FirebaseJobDispathcer, Alarm manager. 我阅读了有关WorkManager,JobScheduler,JobIntentService,FirebaseJobDispathcer,警报管理器的信息。 There is a lot of API s to do that.
有很多API可以做到这一点。
Firstly I tried to check time with interval every minute using alarm manager. 首先,我尝试使用警报管理器每分钟检查一次时间。 But it is not working properly in latest android.
但在最新的android系统中无法正常工作。 There have background restrictions, Doze Mode and standby.
有背景限制,打ze模式和待机状态。 Then I tried JobScheduler but it does not work devices under 21 API.
然后,我尝试了JobScheduler,但它在21 API下无法正常工作。 And FirebaseJobDispatcher required google play service, it is not a good idea.
而且FirebaseJobDispatcher需要Google Play服务,这不是一个好主意。 Finally, I find WorkManager.
最后,找到WorkManager。 But in workmanager and jobscheduler have minimum interval like 15 minutes.
但是在工作经理和工作计划者中,最小间隔为15分钟。
How can I make background service to remind users in specific exact time every day? 如何进行后台服务,以每天的确切时间提醒用户? I am not using the internet, GPS, location.
我没有使用互联网,GPS和位置信息。 Only get time from SQLite and remind in exact time.
仅从SQLite获取时间并提醒准确时间。
In a few months ago, I developed medicine reminder app too. 在几个月前,我还开发了药物提醒应用程序。
I use 'run the daily job in 0:00AM using android-job ' methods to achieve this. 我使用“使用android-job在0:00 AM运行日常工作 ”方法来实现此目的。
In DailyJob, we have this process. 在DailyJob中,我们有此过程。
In Exact job, we display a notification to the user. 在“确切的工作”中,我们向用户显示通知。
I can't attach code because of privacy, but you can achieve the same things. 由于隐私原因,我无法附加代码,但是您可以实现相同的目的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.