
Modern Android 13 Development Cookbook
By :

You can think of WorkManager
as any process that runs in a background thread. When we use the Worker()
, and WorkManager
calls the doWork()
function, this action works in the background thread. In detail, the background thread comes from the Executor
specified in the WorkManager
configuration.
You can also create your own custom executor for your application needs, but if that’s not needed, you can use the pre-existing one. This recipe will explore how threading in a Worker()
works and how to create a custom executor.
In this recipe, since we will be looking at examples, you can follow along by reading and seeing if this applies to you.
Let’s learn how threading works in WorkManager
:
WorkManager
manually, you will need to specify your executor. This can be done by calling WorkManager.initialize()
, then passing the context, and the configuration builder...