I do a ((Context)thingy).bindService(...) from within the onCreate
callback of an Activity.  I've observed that the onServiceConnected()
callback of my associated ServiceConnection does not execute
immediately, but rather, is delayed until after the Activity resumes,
or more precisely, after return from the onResume() callback of the
Activity.

I discovered this the hard way (through a null pointer exception)
because I was unable to use the Service (I call a method in the
Service to start a Thread) immediately upon return from the bindService
() call.

I assume this is normal behavior, but I don't understand why, and I
further assume that there is a good reason for it and that I would
benefit from understanding it.

I'm guessing that maybe the Service isn't eligible to run because
there are fewer than 1 processes bound that are in an active state.
(?)  But once it starts, if I then start the Thread within, it
continues to completion of its task, even if the Activity calls
unbindService() and terminates first!  I don't mind that behavior
(it's what I want to happen), but I want to know whether I can
generally rely on it.  I'm seeking some wisdom from the forum.  Please
help me clear my fog on all these points.

TIA

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