how come? arent foreground services cool anymore t...
# android-architecture
u
how come? arent foreground services cool anymore to not have the process killed?
k
I have never built a chat app, but
Foreground services must display a Notification.
isn’t this a reason for it? Whatsup is using Foreground services for backing up data for sure, the rest should happen seamlessly in background. Is there any reason why you are looking into foreground services?
u
because without foreground service uploading the big file, when going to background, you are background status, which is elligible for killing, while fg service is higher status, making it less likely to get killed upon mem pressure
i
Use work manager
👍 1
u
why, isnt that a wrapper around job scheduler also? file upload in chat needs to be immediate
i
but it'll be done in background and it can be observed inside activity/fragment
don't scehdule it...fire it up right away when you need it
u
sorry thats not the point. point is why they dont use fg service in order not to get killed in bg
i
with new background restrictions fg service might get killed when memory is low but work manager will finish its work, may be later then expected. You can also achieve the same with fg service but WM is easier to implement
u
fg service is exempt from bg restrictions afaik
i
it's not exempted...it's just that it rarely happens if it is long-running, cpu intesive then it might get killed
u
i think you are conflating things. processes get killed on memory pressure by order of they rank, bg is lowest, fg service is middle, foreground is top
cpu is different thing, that is related to screen being off - cpu sleep mode = you can get a wake lock for that
oreo background restrictions are related to location, bluetooth etc of background ranked, whicj you are not when app has fg service
another thing is doze moze, which takes away network and alarms, also fg service not subject
only thing fg service gets fucked by is chinese phones who dont give a fuck about android developers
i
thanks for clearing it up and ur last observation is quite true.
So what did you decided on using?
u
Havent decided yet, got to know first if server supports upload resuming