Reputation: 2753
currently i am using an activity which does asyntask to retrive a list of data from a remote database.
After retrieving under the onPostExecute, i used the method to display out the information gathered from the remote database. Is this the correct way for threading? Previosuly i used a handler in the onPostexecute so that i can intersect the ui thread for displaying information
Upvotes: 0
Views: 102
Reputation: 8242
AsyncTask
is efficient implementation of Haldler
approach . so whenever multithreading needs to interact with UI thread use AsyncTask else follow standard java threading guidelines.
Upvotes: 2
Reputation: 31294
There's lots of ways to achieve multithreading in Android. If you need to perform some background operation then update the UI once this is complete, AsyncTask
s are definitely the way to go. Keep in mind there is a thread limit. Look at this SO question for more information on thread limits.
Upvotes: 2