Feb 21, 2009
At a certain point in my program, when I'm completely done with my service, my activity executes unbindService() and stopService() -- yet the process persists. I can tell that it persists because I run "ps" in "adb -e shell":
View 4 Replies
"adb logcat", I can show you the sequence of events:
ACTIVITY: stopService(serviceIntent); & returns true!
First, my activity calls unbindService(serviceConnection). According to the documentation, unbindService() will "Disconnect from an application service. You will no longer receive calls as the service is restarted, and the service is now allowed to stop at any time." So that is fine, and it is happening.
Appropriately, we see the onUnbind() call happen on the service side. According to the documentation, onUnbind() is called when "all clients have disconnected from a particular interface published by the service." So this confirms the correct service connection is being passed, and that the service is responding accordingly.
Next, my activity calls stopService(serviceIntent), and returns true. According to the documentation, stopService() does the following: "If there is a service matching the given Intent that is already running, then it is stopped and true is returned; else false is returned." Again, this is happening and returning true.
In response, the service's onDestroy() method is called. According to the documentation, onDestroy() is "Called by the system to notify a Service that it is no longer used and is being removed. The service should clean up any resources it holds (threads, registered receivers, etc) at this point. Upon return, there will be no more calls in to this Service object and it is effectively dead."
At this point I expect the process to disappear from the process table. Yet it remains indefinitely. But why?
Also, the process is so persistent that I can bind to it again, and I see that it is the same exact process responding because the PID (process ID) is the same!