android - To download a large file, which is a better approach to use either AsyncTask or Thread? -


I got a sample to download a large data file at the following link,

it seems To be very good (I have not tested it yet). But I have read some posts on stackoverflow, as using the asynchronous class, Thread is not using the class as the above sample.

What should I know, which one should I use to download a file? And if the Ascend Task is better, would you care about me on a sample code? Disclaimer: I am not the developer of Android, the answer comes from the general experience.

Thread class is most suitable for longer running activities, not for asynchronous tasks. Except if you manage the pool of workers, but still the life of the thread is the same or is similar to the application. Think building the thread is a costly operation.

Async Tasks and other assistants are usually for some solo activities, which you want to do in the background so that the app does not block it. They are generally well managed by the platform and are cheap.

My opinion: If you want to load pages sometimes, use AsyncTask if your app will load all-time pages in the background, consider the thread.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -