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 send off an intent, or an AIDL callback method.

On Fri, Oct 1, 2010 at 2:07 PM, Prakash Iyer <thei...@gmail.com> wrote:
> 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 in the original
> Activity instance and you will suddenly not see anything happening. Google
> on the forum and you will see a discussion on a persistent dialog that tells
> you the problem and one solution. Also, once the Activity is out of view, I
> am guessing the OS can destroy it and there isn't much control given to
> AsyncTask.
> 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
> service off in a separate process and use either Intents or AIDL to
> communicate back progress to the Activity.
> So, if your task can be paused and restarted along with the main Activity,
> AsyncTask might work quite well. If not, Service might be the way to go. You
> said the initial sync can take 15-20 min, so be sure you understand how an
> AsyncTask interacts with Activity if it moved away from the foreground coz'
> unless these are your real friends or you are showing something really
> compelling, people will move on...
> On Wed, Sep 29, 2010 at 2:50 AM, Tia <cyclechic...@gmail.com> wrote:
>>
>> 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 process should provide status updates/messages to the
>> UI
>>   5. the user should not be allowed to wander off to other parts of
>> the application and do more work during the synch process.
>>
>> The first time the synch process runs, it may take 10-20 minutes.
>> After the initial synch, less data will be transferred and stored and
>> I expect the process to take 1-2 minutes or less.
>>
>> I've been doing a lot of reading about android's AsychTask and various
>> examples of using a Service ... But I don't fully understand the
>> design considerations and trade-offs of choosing one design over the
>> other. I currently have my demo project stubbed out using an
>> AsychTask. After watching (most of) Developing Android REST client
>> applications:
>> http://code.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html#
>> I'm left confused the design patterns described here feel overly
>> complex, perhaps because I just "don't get it" yet.
>>
>> Would love to hear from some more experienced android developers out
>> there who have already wrestled with these questions.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
~ Jeremiah:9:23-24
Android 2D MMORPG: http://developingthedream.blogspot.com/,
http://diastrofunk.com,
http://www.youtube.com/user/revoltingx

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to