For an activity I have, I want to clean up some files upon on destroy. Would it be better to keep that in a service, or would using coroutines be good enough?
The task should be independent of the activity lifecycle, and does not depend on context.
s
Sam
09/27/2018, 2:01 PM
coroutines or threads don't mean anything for Android. Using them without any foreground component like activity just makes your app eligible to be killed before cleanup. Not to mention the fact that starting Android Pie's bucket system, CPU could be relinquished in certain cases
Sam
09/27/2018, 2:02 PM
Have some foreground service during cleanup and launch coroutines from that service.
Sam
09/27/2018, 2:03 PM
FYI, camera app launches a foreground service for HDR processing of captured photo, food for thought 🙂
a
Allan Wang
09/27/2018, 2:07 PM
Ah okay that was what I was wondering. I usually never use thread pools for this reason.