Reputation: 577
I am currently writing an app that allows a parent to log the events that occurs from their childs phone. The logging takes place in a service which runs in the background. However, the service keeps dying after around a minute..
I dont know what other information you need to help, but any information is useful!
Thanks!
Upvotes: 2
Views: 3235
Reputation: 50538
If you are just binding to the service, then that's why your service is killed when the activity unbinds (Read that in the Docs). If you are using .startService()
and then bind make sure in the onStartCommand()
you return START_STICKY
. You can read why and how here
http://developer.android.com/reference/android/app/Service.html#START_STICKY
And yes, use .startForground()
as well if you are doing something that user is aware of and shouldn't be killed in extreme cases.
Upvotes: 3
Reputation: 63945
try starting the Service as foreground.
Reasons why a Service gets killed are here
Upvotes: 0