If I have a simple service that returns START_NOT_STICKY in onStartCommand
and I both start it explicitly (startService) and bind to it (bindService)
in onCreate of my activity the service gets recreated after it has been
killed over and over again. I unbind the service in onPause of my activity.
Logcat shows that the service is scheduled for restart and is restarted
over and over again. The service is not shown as running after it's been
recreated in Settings -> Apps -> Running.
08-08 21:57:25.081 D/ExampleActivity(23715): onPause
08-08 22:11:44.480 W/ActivityManager( 306): Scheduling restart of crashed
service com.example.service/.MainService in 5000 ms
08-08 22:11:49.519 I/ActivityManager( 306): Start proc
com.example.strangeservice for service com.example.service/.MainService
08-08 22:11:49.597 D/ExampleService(24079): onCreate
08-08 22:27:38.551 I/ActivityManager( 306): No longer want
com.example.service (pid 24079): hidden #16
08-08 22:27:38.574 W/ActivityManager( 306): Scheduling restart of crashed
service com.example.service/.MainService in 5000ms
08-08 22:27:43.629 I/ActivityManager( 306): Start proc
com.example.strangeservice for service com.example.service/.MainService:
pid=24401 uid=10101 gids={1028}
08-08 22:27:43.785 D/ExampleService(24401): onCreate
08-08 22:49:59.871 I/ActivityManager( 306): Process com.example.service
(pid 24401) has died.
08-08 22:49:59.871 W/ActivityManager( 306): Scheduling restart of crashed
service com.example.service/.MainService in 5000ms
08-08 22:50:04.934 I/ActivityManager( 306): Start proc
com.example.strangeservice for service com.example.service/.MainService:
pid=24857 uid=10101 gids={1028}
08-08 22:50:05.051 D/ExampleService(24857): onCreate
I thought START_NOT_STICKY meant that once it gets killed by Android it
wont be restarted unless I explicitly start it again. Or does binding to a
service override that and make the service sticky?
I've been testing this on a Galaxy Nexus with stock Android 4.1.1.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en