https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
u

ursus

02/10/2019, 1:58 AM
how come? arent foreground services cool anymore to not have the process killed?
k

kioba

02/10/2019, 12:49 PM
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

ursus

02/10/2019, 9:36 PM
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

ibraiz_teamo

02/11/2019, 7:11 AM
Use work manager
👍 1
u

ursus

02/11/2019, 2:05 PM
why, isnt that a wrapper around job scheduler also? file upload in chat needs to be immediate
i

ibraiz_teamo

02/12/2019, 5:56 AM
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

ursus

02/12/2019, 2:29 PM
sorry thats not the point. point is why they dont use fg service in order not to get killed in bg
i

ibraiz_teamo

02/14/2019, 7:08 AM
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

ursus

02/14/2019, 8:22 AM
fg service is exempt from bg restrictions afaik
i

ibraiz_teamo

02/14/2019, 8:46 AM
it's not exempted...it's just that it rarely happens if it is long-running, cpu intesive then it might get killed
u

ursus

02/14/2019, 1:47 PM
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

ibraiz_teamo

02/19/2019, 6:33 AM
thanks for clearing it up and ur last observation is quite true.
So what did you decided on using?
u

ursus

02/19/2019, 3:26 PM
Havent decided yet, got to know first if server supports upload resuming
2 Views