Reputation: 31
I have a backgroud service that acquires a "partial wake lock" and starts an handler thread. I know that, for some reasons, Android can kill this service and restart it again. My question is, what happens to my thread? will it be stopped calling some methods, brutally destroyed or does it continue the execution normally? Regarding the wake lock, will it somehow be released by the system or not?
Upvotes: 0
Views: 125
Reputation: 15165
Will it be stopped calling some methods, brutally destroyed or does it continue the execution normally?
According to my experiment on small RAM of the Android device, the Service
can be killed by Android system on high memory pressure. Android system doesn't trigger your Service
to call onDestroy
method. I think, the system pauses the Service
's thread. Even if the Service
return START_STICKY
or START_REDELIVER_INTENT
, but they don't guarantee that your Service
will be started again.
Regarding the wake lock, will it somehow be released by the system or not?
Android system doesn't guarantee to releases the wakelock, unless you call startWakefulService(context, service)
. It uses wakelock as long as your Service
is running.
Upvotes: 1