Friday, June 19, 2015

AsyncTask

AsyncTask:
AsyncTask is an abstract class provided by Android which helps us to use the UI thread properly. This class allows us to perform long/background operations and show its result on the UI thread without having to manipulate threads.

advantages of using AsyncTasks:
  1. Easy to learn and implement.
  2. It is having good process control.

Disadvantages of using AsyncTasks:
  1. No orientation-change support.
  2. No ability to cancel network calls.
  3. As well as no easy way to make API calls in parallel.
  4. With the exception of Froyo and Gingerbread, Async Tasks (by default) run in a serialised fashion.
  5. In a practical sense, this means that only one AsyncTask is running at any given time.
  6. Views that require multiple API calls (the DashBoard currently has 7) run extremely slow, sometimes taking multiple seconds to load.
For this reasons we should use third-party libraries for network operations Like Volley,Retrofit,Robospice..etc.

No comments:

Post a Comment