SyncAdapter vs JobScheduler

大城市里の小女人 提交于 2019-12-22 03:25:48

问题


Excluding the fact that JobScheduler only supports API > 21 - are JobSchedulers designed to fully replace SyncAdapters? Or does SyncAdapter contain any functionality lacking by JobScheduler?

My use case is syncing an RSS feed every couple of hours. This is doable with a JobScheduler - right?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/30193676/syncadapter-vs-jobscheduler

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