Asynctask Implement Asynchronous processing task: http://www.javaeye.com/topic/827513
We all knowAndroidProvides a simpler method for processing multiple tasks than threads.AsynctaskAsynchronous task class, relative to the threadAsynctaskThe internal implementation of simple task processing is more secure.AndroidOfHandlerMechanism, which can be used for common file downloadsAsynctaskClass, In the Android systemBrowserThis type of download is used in the browser.WebServerURLOfFaviconIcon. See the following link:
Asynchronous tasks of Android asynctask
Notes about asynctask (from androiddoc ):
Threading rules <br/> there are a few threading rules that must be followed for this class to work properly: <br/> (1) the task instance must be created on the UI thread. <br/> (2) execute (Params ...) must be invoked on the UI thread. <br/> (3) do not call onpreexecute (), onpostexecute (result), doinbackground (Params ...), onprogressupdate (Progress ...) manually. <br/> (4) the task can be executed only once ( Exception will be thrown if a second execution is attempted.) <br/> pay attention to the parameter transfer between the four functions! For more information, see the documentation.
Android multithreading: http://www.360doc.com/content/10/1108/11/3779243_67585561.shtml
Progressdialog use: http://www.javaeye.com/topic/569152
Multithreading in Android: http://justjavac.javaeye.com/blog/699735
Android multithreading: http://blog.csdn.net/anghlq/archive/2010/05/20/5612592.aspx
Http://www.eoeandroid.com/thread-2089-1-1.html
Note that:
In Android, non-UI threads cannot touch the UI class.That is to say, non-main threads cannot directly refresh the interface of the main thread, otherwise it will report
Android. View. viewroot $ calledfromwrongthreadexception: only the original thread that created a view hierarchy can touch its views. (visible: http://hi.baidu.com/lfcaolibin/blog/item/5cdf623c39ea760bbaa16738.html)
The solution is to create another handler, encapsulate the code of the changed UI into it, and the sub-thread calls the handler. after the work is completed, a message is sent to the message queue, the main thread updates the UI status when idle (most of the time should be real-time ).