10

Currently, in Android, to do a task periodically based on time or any other factors like charging state, network state etc, the basic three options are: Android AlarmManager (which works periodically based on time), GCMTaskService (requires Google Play Service on device) and JobScheduler (requires Android Version > 21). Recently, I've come across these two libraries for scheduling jobs, one from Firebase and one from Evernote.

My primary question is: How do these two libraries compare? What are their strength and weaknesses?

I want to build an app where a user is reminded of taking medicines periodically after certain time period.

My secondary question is: would simple AlarmManager suffice for this purpose, or should I go for any of these two libraries?

Thanks.

4

1 回答 1

8

这两个库如何比较?他们的优势和劣势是什么?

Firebase JobDispatcher github 页面中有一个很好的比较表:

在此处输入图像描述

关键区别在于 Google Play 服务的存在:Firebase 需要设备来安装它,而 Evernote 是独立于 Play 服务的。

我想构建一个应用程序,提醒用户在特定时间段后定期服药。简单的 AlarmManager 是否足以满足此目的,还是我应该使用这两个库中的任何一个?

经验法则是,你很可能不需要AlarmManager,因为它是一个电池消耗器。作业调度程序的一个关键特性是它们组合作业并在单个窗口中执行它们,因此设备不会太频繁地唤醒。

您最好坚持使用工作调度员,除非服药应该有确切的时间,如警报(例如,您想通知用户在 3 小时内准确服药)。

于 2017-04-04T06:14:38.337 回答