Android-Optimizing UI Performance (1)-reduces the blocking time of the main thread

Source: Internet
Author: User

android-Optimizing UI Performance (1)-reduces the blocking time of the main thread
one reduces the blocking time of the main thread
Android has provided a way to implement Asynctask to generate new asynchronous tasks from the main thread.
Define and implement the following classes (methods are automatically called by the system):

 Public  class downloadfilesasynctask extends asynctask<URL,  Integer,Long>{    /* (non-javadoc) * Background execution function * @see android.os.asynctask#doinbackground (params[]) */@OverrideprotectedLong doinbackground (URL ... arg0) {//TODO auto-generated method stub        return NULL; }//Execute after background thread finishes@Overrideprotected voidOnPostExecute (Long result) {//TODO auto-generated method stub}//execute before background thread starts@Overrideprotected voidOnPreExecute () {//TODO auto-generated method stub        Super. OnPreExecute (); }//Set progress updates, such as setting a displayed progress bar@Overrideprotected voidOnprogressupdate (integer ... values) {//TODO auto-generated method stub}

By an asynchronous task, you can reduce the blocking time of the main thread

Copyright NOTICE: Welcome to communicate the error of the article, must be open-minded to answer, QQ872785786

Android-Optimizing UI Performance (1)-reduces the blocking time of the main thread

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.