Is there some kind of coroutine scope already hand...
# android
d
Is there some kind of coroutine scope already handled by Android Lifecycle components for Services and IntentServices?
a
What kinds of services are you working with? You mention IntentService, have you looked at WorkManager?
For WM there's a
CoroutineWorker
available that plays quite nicely with them
d
I've seen it, but I have a SyncAdapter that needs to run a whole chain of things, and I was hoping to save the refactoring for later 🙃... so if everything is going towards
WorkManager
then `Service`s are only for building chains of work items and launching them?
And they apply also for SyncAdapters? The only problem is that there won't really be any way to report back to the SyncAdapter if there were any errors...
That's really part of the point of SyncAdapters, they run themselves again with some backoff type logic.
d
There is
LifecycleService
class you can extend instead of
Service
This is part of androidx.lifecyle library
d
Is there any CoroutineScope that comes with that @dekans?
d
lifecycleScope
will come with it, as it's a
LifcyleOwner
🙂
👍🏼 1
d
Is there something similar for
IntentService
?
Then again, it might be easy to mimic one using a buffered
Flow
, no?
d
I dont think so, but in this case, implementation is pretty easy. Check the
LifecycleService
source