Mark,

I'm almost certain that I'm doing something wrong. I would even dare to
venture that I'm taking the wrong approach entirely. I don't know what I
don't know.

My plan for the Connection Service is to manage the connection to the remote
server entirely in the background. I am planning for the Service to detect
server availibility, handle Wifi - 3g transitions, bad server IP, etc. It
works to keep the connection alive. No matter the status of the Connection,
I want the Service to run in the background and provide a mechanism for the
Activities that bind to it to check for a valid Connection. (static
boolean?) Then I'll leave the responsiblity of taking the appropriate action
for the User to the Activity. Additionally, if no Activities are bound to
the Service, it provides information to the User via Notifications.

Yes, the Connection extends Thread.

If I start a Thread in an Activity, does that Thread need to complete
execution before I can transition to the next Activity?

Thanks,
J


On Fri, Apr 9, 2010 at 8:30 AM, Mark Murphy <[email protected]> wrote:

> Jason LeBlanc wrote:
> > I have tried moving the start Service call to a manually-managed thread
> > within the Activity, but with the same results. The UI Thread still
> > hangs when the Service attempts to connect to an invalid server.
>
> :: shrug ::
>
> If you think this is a bug in Android, create a sample project that
> demonstrates it and post it on http://b.android.com.
>
> Otherwise, you're doing something wrong.
>
> > In the Service, I instanciate a Connection object from which the
> > class extends a Thread.
>
> Are you saying that Connection extends Thread?
>
> > It's in the constructor of that the Connection
> > class where I create a new Socket.
>
> A Thread object is not on a separate OS thread until the Thread is
> called with start(). Notably, the Thread constructor is called on the
> thread of whoever invokes the constructor. Background work occurs on the
> Thread's run() method.
>
> You want to do the IP connection in the background. Hence, do not do it
> in a Thread constructor.
>
> --
> 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]<android-developers%[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.
>

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