0

When an application needs to upload many large files, which would be a better solution:

1) Doing this on a separate process (i.e. remote service)?

2) Using a separate thread (or AsyncTask)?

Is there a clear and definite answer to this?

The application, by the way, is uploading things all the time - usually very small chunks of data. Every now and then it needs to send large files, so I want to do that with a separate mechanism then the one I am using. (BTW for the small chunks I am using a single task thread which works great)

I also understand that AsyncTask is good for one-time operations and threads are better for many-operations

EyalBellisha
  • 1,874
  • 19
  • 28
  • Possible duplicate: http://stackoverflow.com/questions/13706059/is-it-better-to-use-asynctask-or-service-to-upload-a-file-in-background and http://stackoverflow.com/questions/6957775/android-asynctask-vs-service – damix911 Apr 18 '13 at 07:47
  • I have read the two before posting this question. My question is different since I am asking about using a separate process versus using a separate thread – EyalBellisha Apr 18 '13 at 08:01

3 Answers3

0

It is always better to use an AsyncTask as AsynsTask is nothing but a thread as since you are uploading multiple files, so multithreading is necessary to avoid any exception

Parijat Bose
  • 380
  • 1
  • 6
  • 22
0

There is no need to create a whole new process. A background service is the best option. Bind your activity to your service, and activate it whenever you want to send data. It would be better to send using threads/AsyncTask in the service(Yes you need to do multithreading even in the service). I prefer AsyncTask as they are easy to manage.

shiladitya
  • 2,290
  • 1
  • 23
  • 36
0

According to Is it better to use AsyncTask or Service to upload a file in background? a service may be better, because services are especially suited for doing things in the background for a prolonged period of time.

The same page also mentions that AsyncTasks are likely to be killed as the Activity goes to background.

Community
  • 1
  • 1
damix911
  • 4,165
  • 1
  • 29
  • 44