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
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
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
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
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
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
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
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
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
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
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
11 matches
Mail list logo