[Android multithreading] Some posts and articles progressdialog, asynctask, thread

Source: Internet
Author: User

 

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 ).

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.