SyncAdapter vs JobScheduler

末鹿安然 提交于 2019-12-05 00:40:55

I would say JobScheduler is not a direct substitution for SyncAdapter, which has a much more specialized purpose (transferring data between the device and a server). JobScheduler, on the other hand, serves to schedule tasks to be executed at some point of time in future - just like AlarmManager - but with a broader potential.

By the way, there's an attempt to 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!