Issue
My Service is executing onDestroy()
raised by calling stopSelf()
. I am doing a longer lasting clean up operation (can be 10, 30 or 90 seconds) in onDestroy()
. What happens, if my Service gets started now?
- Will Android create a new Instance of the Service?
- Will the
onStartCommand()
of the current service get called? - Something else happens?
Solution
onDestroy()
gets called on the UI thread (also called the main thread). So does onStartCommand()
. Hence, until you return from onDestroy()
no other framework method can get called - not only for this Service
but for any other Service
running in the same process. Also, no framework callback for any other component (Activity
etc) will get called.
Of course, in practice, if you really block for 10 or more seconds in any lifecycle method of any component, you will almost definitely see an Application Not Responding message.
Answered By - curioustechizen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.