Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Jason LeBlanc
Dianne, Thanks for the advice. AsyncTask seems to be a popular recommendation. For some reason when I first read about it, I was turned away by the fact that it could only be called once. I actually ordered a book on concurrency yesterday, so hopefully I can get a better handle on multthreading.

Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Dianne Hackborn
I strongly recommend using IntentService, which takes care of the threading for you. Unless you are good at multithreading (I will claim that 90% of developers are not) then it is a good idea to stay away from Thread and use some higher-level facilities like IntentService, AsyncTask, etc. On Fri,

Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Mark Murphy
Jason LeBlanc wrote: > Yes, the Connection extends Thread. Then be sure not to do anything time-consuming in the Connection constructor. Put the time-consuming stuff in run(). In this case, that includes opening your socket connection, because while it might not be time-consuming normally, it will

Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Jason LeBlanc
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

Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Mark Murphy
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 sampl

Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Jason LeBlanc
Mark, 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. Agus, In the Service, I instanciate a Connection object from which the class extends

Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Agus
Have you tried launching a thread inside your Service and have your Service binded/started in the Application context? On Fri, Apr 9, 2010 at 5:23 AM, 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 a

Re: [android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Mark Murphy
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

[android-developers] Do Services *really* run in the Background?

2010-04-09 Thread Jason LeBlanc
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