SyncAdapter 与 JobScheduler
SyncAdapter vs JobScheduler
排除 JobScheduler
仅支持 API > 21 的事实 - JobSchedulers
是否旨在完全取代 SyncAdapters
?或者 SyncAdapter
是否包含 JobScheduler
缺少的任何功能?
我的用例是每隔几个小时同步一次 RSS 提要。这可以通过 JobScheduler 实现 - 对吗?
我会说 JobScheduler
不是 SyncAdapter
的直接替代品,后者具有更专业的用途(在设备和服务器之间传输数据)。另一方面,JobScheduler
用于安排在未来某个时间点执行的任务 - 就像 AlarmManager
- 但具有更广泛的潜力。
顺便说一句,有人试图 backport JobScheduler
。
SyncAdapter
The framework continues to provide the SyncAdapter class for managing tasks that sync data between the device and a server. Sync adapters are designed specifically for syncing data between a device and the cloud; you should only use them for this type of task. Sync adapters are more complex to implement than the libraries and APIs mentioned above, because they require at least a fake authenticator and content provider implementation. For these reasons, you typically should not create a sync adapter just to sync data to the cloud in the background. Wherever possible, you should instead use JobScheduler, Firebase JobDispatcher, or GCM Network Manager .
In Android N (API level 24), the SyncManager sits on top of the JobScheduler. You should only use the SyncAdapter class if you require the additional functionality that it provides.
https://developer.android.com/topic/performance/scheduling.html
排除 JobScheduler
仅支持 API > 21 的事实 - JobSchedulers
是否旨在完全取代 SyncAdapters
?或者 SyncAdapter
是否包含 JobScheduler
缺少的任何功能?
我的用例是每隔几个小时同步一次 RSS 提要。这可以通过 JobScheduler 实现 - 对吗?
我会说 JobScheduler
不是 SyncAdapter
的直接替代品,后者具有更专业的用途(在设备和服务器之间传输数据)。另一方面,JobScheduler
用于安排在未来某个时间点执行的任务 - 就像 AlarmManager
- 但具有更广泛的潜力。
顺便说一句,有人试图 backport JobScheduler
。
SyncAdapter
The framework continues to provide the SyncAdapter class for managing tasks that sync data between the device and a server. Sync adapters are designed specifically for syncing data between a device and the cloud; you should only use them for this type of task. Sync adapters are more complex to implement than the libraries and APIs mentioned above, because they require at least a fake authenticator and content provider implementation. For these reasons, you typically should not create a sync adapter just to sync data to the cloud in the background. Wherever possible, you should instead use JobScheduler, Firebase JobDispatcher, or GCM Network Manager .
In Android N (API level 24), the SyncManager sits on top of the JobScheduler. You should only use the SyncAdapter class if you require the additional functionality that it provides.
https://developer.android.com/topic/performance/scheduling.html