Android may kill the process and thus the service running in the
process, once onDestroy() returns (after sending a message to the
worker thread).
But how will I make sure that the service has completed it's clean up
operations (ex. saving some data on to some storage, etc...), if any?

The main thread nevers gets blocked in any other scenario except
onDestroy().
Do you have any other mechanism to achieve this behavior in the
platform?

On May 27, 2:23 am, Dianne Hackborn <[email protected]> wrote:
> Blocking in onDestroy() waiting for the background thread to complete
> basically defeats the purpose of doing work in a background thread.
>
> On Tue, May 26, 2009 at 7:09 AM, Gautam 
> <[email protected]>wrote:
>
>
>
>
>
>
>
> > Hi,
>
> >     I'm implementing a service that contains a thread to handle all
> > time consuming operation. My core service logic is in a different
> > thread than the ui or main thread. According to the Android document,
> > when the OS plans to free some system resource, it will call onDestroy
> > () on the service and only when onDestroy() returns it will kill the
> > process hosting the service, thus giving opportunity to the service to
> > cleanup.
>
> >     Now, when onDestroy() is called, I want to send a message to my
> > service thread to do the necessary cleanup. Only when the service
> > thread acknowledges that the cleanup or shutdown is complete, onDestroy
> > () should return.
> > I could find a way to send asynchronous messages to threads and the
> > corresponding processing of the messages, but not able to figure out
> > how I need to implement onDestroy(), such that it would send a message
> > to the service thread and should wait for a result, before returning.
>
> >    Appreciate if someone can comment on my understanding of onDestroy
> > () and provide some solution to the above problem.
>
> > Thanks and Regards,
> > Gautam.
>
> --
> 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.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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