Akshay
Akshay

Reputation: 815

Service on Android Oreo

On Android Oreo, If my app starts a service while in foreground and then I close my app, will the service be killed later on? or will it stay alive?

From this video post it seems like the service will be killed if the app is in background, https://www.youtube.com/watch?v=Pumf_4yjTMc&t=198s

However, while testing, the service is quite alive. Will appreciate any productive feedback.

Upvotes: 0

Views: 773

Answers (3)

Akshay
Akshay

Reputation: 815

Thanks for your answers! Appreciate your responses. It Was my bad as I switched the work branch that wasn't targeting API 26. I think, it's worth mentioning that the above restriction is only applicable if the app is targeting api 26 (Android O). I have started moving to Job scheduler, and that seems to be working on Android O.

Upvotes: 0

tyczj
tyczj

Reputation: 73753

The service gets killed eventually

When an app goes into the background, it has a window of several minutes in which it is still allowed to create and use services. At the end of that window, the app is considered to be idle. At this time, the system stops the app's background services, just as if the app had called the services' Service.stopSelf() methods.

https://developer.android.com/about/versions/oreo/background.html

Upvotes: 3

Crono
Crono

Reputation: 2054

The service´s call and all of your current aplication´s process will be killed if you close or destroy your application, cause all of these process are linked to your app´s lifecycle, if the lifecycle is closed, killed or crashed, all of the processes go to the same end.

Upvotes: 2

Related Questions