Hello service developers!

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":

USER     PID   PPID  VSIZE RSS   WCHAN    PC         NAME
app_19   2041  23    108360 16128 ffffffff afe0c534 S
com.example.helloactivity
app_19   2049  23    95732 13336 ffffffff afe0c534 S
com.example.helloactivity:remote

Thanks to "adb logcat", I can show you the sequence of events:

ACTIVITY: context.unbindService(serviceConnection);

SERVICE: onUnbind();

ACTIVITY: stopService(serviceIntent); & returns true!

SERVICE: onDestroy();

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!

Can anyone shed any light on this?

Also, can anyone out there use "ps" to see if their process is still
there when you think it should be gone?

Thanks a lot!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to