Jason LeBlanc wrote:
> I have a scenario where I start a Service from a splash screen. If I
> intentionally cause problems in that Service (such as an invalid port
> for the Socket connection) my UI Thread locks up. I have put a Timer in
> the Service, and have it perform logging at every tick. The Timer works
> from within the Service without flaw. So from that, I think I have
> determined that only the UI Thread is suffering.
>  
> If I start a Service from an Activity and that Service has an issue
> (i.e. server connection problems), should that result in a lockup in the
> UI thread from which it was launched?

All callbacks into the Service -- onCreate(), onStart(), onBind(),
onDestroy(), etc. -- are called on the main application thread. This is
the same behavior as is for activities, broadcast Receivers, etc.

The problem is that "background" has two meanings. Services are
automatically in the "background" visually (i.e., they are not on the
screen). Services are *not* automatically in the "background" from a
threading standpoint.

Hence, you still will want to use AsyncTask, or IntentService, or
manually-managed threads, to have work done off the main application thread.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Online Training: 10-14 May 2010: http://onlc.com

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to