If nothing else, your thread needs to return to the event loop for it to be
able to dispatch the next operation to do -- which may be to call
onDestroy() of the service.  You definitely don't want the framework
callings these things from arbitrary random points within your own calls to
the framework.

On Fri, Aug 6, 2010 at 5:04 PM, TreKing <[email protected]> wrote:

> On Fri, Aug 6, 2010 at 6:18 PM, Rajesh Bachani 
> <[email protected]>wrote:
>
>> Now when I call the stopService() method from A, the onDestroy() method in
>> S is not called immediately.
>>
>
> The doc for stopServices says: "Request that a given application service
> be stopped." Key words being "request" and "stopped".
>
> From the Service doc:
>
> A service can be both started and have connections bound to it. In such a
>> case, the system will keep the service running as long as either it is
>> started or there are one or more connections to it with the
>> Context.BIND_AUTO_CREATE<http://developer.android.com/reference/android/content/Context.html#BIND_AUTO_CREATE>
>>  flag.
>> Once neither of these situations hold, the service's 
>> onDestroy()<http://developer.android.com/reference/android/app/Service.html#onDestroy()>
>>  method
>> is called and the service is effectively terminated.
>
>
> My understanding: You're asking the system to stop the service, not to
> destroy it. That will happen automatically, later, when it determines the
> Service is no longer being used. For example, you could have another
> activity that is bound to the service, so although it can be stopped, it
> wouldn't be destroyed.
>
> Why is this causing you a problem?
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

Reply via email to