Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-03 Thread Prakash Iyer
Dianne, With all due respect, HandlerThread or Thread do NOT convey the message that they can be used with the UI in the same way that an AsyncTask does. In fact even a small para saying something like AsyncTask runs as a separate thread and does interact with the Activity's lifecycle. It is

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-02 Thread Dianne Hackborn
On Fri, Oct 1, 2010 at 2:07 PM, Prakash Iyer thei...@gmail.com wrote: Service, OTOH, is designed to work in the background without requiring user interaction. Problem is that for your Activity to display the results it must somehow interact with your service. Ideally you will want to spawn the

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-02 Thread Prakash Iyer
I'm not sure I agree with your comment that it is the wrong question. In fact your explanation of how a majority of the cases a Service runs in the same process is precisely why most people will consider these as alternatives. I was trying to point out to the OP that if the OP ever wanted to

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-02 Thread Tom Gibara
AsyncTask is excellently documented: http://developer.android.com/reference/android/os/AsyncTask.html http://developer.android.com/reference/android/os/AsyncTask.htmlAsyncTask has no interaction with the Activity lifecycle, except for that which you introduce with your own code. It's for

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-02 Thread Prakash Iyer
Each his own. Try writing a AsyncTask that say lives for more than 10s and in the final result say updates a text field. Now before the AsyncTask completes, just change the orientation. I'd bet most developers would assume the text field will get updated. Most developers would be wrong as the

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-02 Thread Tom Gibara
AsyncTasks can be used in a number of contexts, not only in Activities. And where they are used in activities, there are many way of plumbing them to the activity lifecycle. Here are three scenarios that I would generally use AsyncTasks for (rather than services): 1) Dynamically rendering an

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-02 Thread Agus
item #5 seems not user friendly to me. assuming that user can open other applications on the phone and since that the sync takes 10-20 minutes i suggest initiating an asynctask in a service. If you use a service, android will try hard not kill your application process. On Tue, Sep 28, 2010 at

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-02 Thread Dianne Hackborn
On Sat, Oct 2, 2010 at 3:39 PM, Prakash Iyer thei...@gmail.com wrote: Each his own. Try writing a AsyncTask that say lives for more than 10s and in the final result say updates a text field. Now before the AsyncTask completes, just change the orientation. I'd bet most developers would assume

[android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-01 Thread Tia
I'm designing an android app which will need todo the following steps: 1. user pushes a button or otherwise indicates to synch data. 2. synch process will use REST web services to move data to and from the server. 3. the data will be stored locally in a sqlite database. 4. the synch

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-01 Thread Prakash Iyer
Not sure I am experienced but I did use both AsncTask and Service, so here is my opinion. AyncTask works great - until the user does something to visually alter your app, e.g. changes orientation or goes to the home screen. Reason is that the AsyncTask will most likely be referring to UI elements

Re: [android-developers] android design considerations: AsynchTask vs Service (IntentService?)

2010-10-01 Thread Miguel Morales
You will more than likely need a service. It'll save you a lot of work later on. You would start your service when your app starts, then your activities bind to is and communicate via something like AIDL. So the activity can tell the service to start a sync. And when the service is done, it can