6

Advanced Usage of WorkManager in multi-process apps

 3 years ago
source link: https://medium.com/androiddevelopers/advanced-usage-of-workmanager-in-multi-process-apps-4ea2d7e75501
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Advanced Usage of WorkManager in multi-process apps

In WorkManager 2.5, we made it easier for multi-process apps to reach out to a specific WorkManager instance running in a designated process.

Now, in WorkManager 2.6, we’ve taken it a step further to add support for Workers to run in any process and allow workers to be bound to a particular process. Multi-process support is particularly useful for apps that need to run Workers in multiple processes. Most apps work well in a single process. But those that require more than one process used to have a hard time managing work between processes. Until now!

Starting from WorkManager 2.6, you can bind a worker to a specific process, using RemoteListenableWorker or RemoteCoroutineWorker. For workers implemented in Kotlin, you should use RemoteCoroutineWorker. Otherwise, you should use RemoteListenableWorker. In this article, we’ll demonstrate a Worker implemented in Kotlin, but for a similar Java implementation, check out our sample linked below.

A RemoteCoroutineWorker can be implemented just like CoroutineWorker. But instead of overriding `doWork`, you override `doRemoteWork`, and then bind to a specified process with two extra arguments provided as part of the input data when building the work request: ARGUMENT_CLASS_NAME and ARGUMENT_PACKAGE_NAME:

For each RemoteWorkerService, you’ll also need to add the service definition in the AndroidManifest like so:

To see these new functionalities in action, check out the new WorkManager Multiprocess Sample that utilizes both RemoteCoroutineWorker and RemoteListenableWorker.

You can also see a detailed list of the changes and improvements we’ve made in WorkManager 2.6 in our release notes here.

Lastly, if you have any feature requests or issues related to WorkManager, feel free to file an issue in our public tracker.


Recommend

  • 51
    • 掘金 juejin.im 6 years ago
    • Cache

    新架构组件: WorkManager

    5月8号, I/O大会上又推出了两个新的Architeture Component库: Navigation与WorkManager. 这里就先介绍一下WorkManager. 一. WorkManager的一句话介绍 其实就是"管理一些要在后台工作的任务,

  • 64
    • 掘金 juejin.im 6 years ago
    • Cache

    [译] 从Service到WorkManager

    原文地址:Services. The life with/without.WorkManager 原文作者:Yonatan V. Levin 随着Android版本的不断更新,如何正确的处理后台任务变得越来越复杂。因此, Google发布了 WorkMan

  • 68

    Android Jetpack带来WorkManager、Navigation等特性

  • 85

    At Google I/O 2018 , Google announced the WorkManager library as part of the Android Jetpack component set. Moving forward, WorkManager replaces JobScheduler as...

  • 66

    WorkManager is for deferrable background task that needs a guaranteed execution, let’s get started an example to explan how to use it Overview One of the core features in our app are publishin...

  • 228
    • wl9739.github.io 6 years ago
    • Cache

    在 WorkManager 中处理异步任务

    WorkManager 是 Android Jetpack 中的新组件,用于负责管理后台任务。关于这个组件的介绍就不多说了,网上到处都是,这里分享一下在 WorkManager 中处理异步任务的方法。 我们知道,在 WorkManager 中,处理任务的方式是创建一...

  • 45

    Android Jetpack WorkManager Stable Release 2019-03-06ad...

  • 12

    Using WorkManager in multi-process apps📝 The recent release of WorkManager 2.5.0 enables easier usage in a multi-process environment and provides several stability improvements.So if you have an app...

  • 13
    • py.hashnode.dev 3 years ago
    • Cache

    WorkManager multi-process for libraries

    Cover image: Beacons by Romain Guy. Summary This blog shows how LeakCanary builds on top of WorkManager to run work in a se...

  • 7
    • medium.com 2 years ago
    • Cache

    WorkManager in multi-module apps

    WorkManager in multi-module apps

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK