本文介绍了Android WorkManager与JobScheduler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们已经已经使用新的Android WorkManager 有一个 JobScheduler 以及一些漂亮的反向端口( Android作业 FirebaseJobDispatcher )具有相同的功能?它具有任何杀手级功能吗?因为我没有看到任何内容,所以我想迁移到另一个调度程序.

解决方案

"WorkManager具有许多不错的功能,但其主要目标是在较旧的设备上使用JobScheduler的API" ...等等,但是我们已经有了一些移植.他们怎么了?简而言之:

  1. FireaseJobDispatcher 很好,但它需要Google Play strong>例如,如果我们的目标是中国,那么就安排不好的工作.

  2. Evernote的 AndroidJob 是具有许多功能的优秀反向端口.天哪,安排任何工作的最佳选择.但是,现在该库的最新版本在后台使用了前述的WorkManager.而且,不幸的是,迟早该库将被弃用:

他们建议切换到WorkManager,因为它提供了更多功能,并且还给了我们简短的比较:

|   Feature          | android-job | WorkManager |
| ------------------ | ----------- | ----------- |
| Exact jobs         | Yes         | No          |
| Transient jobs     | Yes         | No          |
| Daily jobs         | Yes         | No          |
| Custom Logger      | Yes         | No          |
| Observe job status | No          | Yes         |
| Chained jobs       | No          | Yes         |
| Work sequences     | No          | Yes         |

Imo,最后3个功能非常有用,并且仅由WorkManager支持.因此,我对最后一个问题的答案是肯定的,它确实具有一些杀手功能:

  • 不需要Google Play
  • 可查询
  • 可束缚
  • 机会主义

要了解有关WorkManager的更多信息,请务必观看Sumir Kataria的此演讲 >

P.S.如果有人知道为什么 FirebaseJobDispatcher Google工程师积极支持而不是被弃用,请在下面的评论中写下:)

Why do we need the new Android WorkManager if we already have a JobScheduler along with a few nifty backports (AndroidJob and FirebaseJobDispatcher) with the same functionality? Does it have any killer-features or something? Because I don't see anything that makes me want to migrate to the yet another scheduler.

解决方案

"WorkManager has a lot of nice features but its main goal is to use the JobScheduler's API on older devices"... Wait, but we already have some backports. What's wrong with them? To cut it short:

  1. FireaseJobDispatcher is fine but it requires Google Play to schedule jobs which isn't good if we're targeting China, for example.

  2. Evernote's AndroidJob is an excellent backport with a lot of functionality. Imho, it was the best choice for scheduling any work. But now the latest version of the library uses the aforementioned WorkManager under the hood. And, unfortunately, sooner or later the library will be deprecated:

They suggest to switch to the WorkManager because it provides more features and they also give us a short comparison:

|   Feature          | android-job | WorkManager |
| ------------------ | ----------- | ----------- |
| Exact jobs         | Yes         | No          |
| Transient jobs     | Yes         | No          |
| Daily jobs         | Yes         | No          |
| Custom Logger      | Yes         | No          |
| Observe job status | No          | Yes         |
| Chained jobs       | No          | Yes         |
| Work sequences     | No          | Yes         |

Imo, the the last 3 features are very useful and supported only by the WorkManager. So the answer to my last question is yes, it does have some killer-features:

  • No Google Play required
  • Queryable
  • Chainable
  • Opportunistic

To learn more about WorkManager one should definitely watch this talk by Sumir Kataria

P.S. If anyone knows why FirebaseJobDispatcher is actively supported by Google engineers instead of being deprecated write in the comments below :)

这篇关于Android WorkManager与JobScheduler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 22:25