O
O
orbit0702019-05-23 12:32:18
Android
orbit070, 2019-05-23 12:32:18

Is it no longer customary to use services for background tasks in android?

Hello.
I'm studying android, on startandroid I saw this:


Once upon a time, services were designed for background work. But in Android 8 they were very limited: if the application is not active, then the service will be stopped after some time. And long before Android 8, developers started using tools like JobScheduler or Firebase JobDispatcher to run background tasks.
WorkManager is a new tool. It allows you to run background tasks sequentially or in parallel, transfer data to them, get a result from them, monitor the execution status and run only if the specified conditions are met.

I would like to know how true this is? For background tasks, is it always worth using WorkManager or is it not so simple and depends on some details? I will be grateful for the educational program

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Zagaevsky, 2019-05-23
@orbit070

Services in 2019 should actually only be used for foreground tasks that are not directly on the screen. A la music player and playing music, and the like.
Any "long operations and calculations", any uploads of large files to the network and the like should be done using WorkManager'a.
Some time ago, I also recommended using the evernote library , for example, we haven’t migrated from it in the prod yet.

I
illuzor, 2019-05-23
@iLLuzor

Background tasks can be very different, for example, accessing the network or accessing the database in a separate thread are also background tasks, but they (in most cases) do not need services or WorkManager.
It is worth reading about the limitations of different versions of android (menu on the left) and learn how and where to use WorkManager .

everything is so simple and depends on some details?
Everything is ambiguous, you don’t need to bury services, there are cases when you can’t do without them, for example, Foreground Service.

O
Oleg, 2019-05-23
@402d

teach and teach. I've been studying Java for a year and a half.
I missed the work manager, after reading about it now, I can say.
It was easier to do something through it instead of asynctasks.
But what services do for me is not transferred to it at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question