Application+handle+task

Source: Internet
Author: User

Application application, like Activity,service, is a system component of the Android framework, and the Android system creates an object of the application class for each program runtime and creates only one, So application can be said to be a class of Singleton (singleton) mode. And the life cycle of the Application object is the longest in the whole program, and its life cycle is equal to the program's life cycle. Because it is a global singleton, the objects obtained in different activity,service are the same object. So through the application to do some, data transfer, data sharing, such as data caching operations.

Handle when we are dealing with downloads or other tasks that need to be performed for a long time, if you put the handler function directly in the activity's OnCreate or onstart, it will cause the entire activity to be unresponsive during execution, and if the time is too long, the program will hang. handler is the ability to put these functions into a separate thread to execute, and not affect the activity. When processing is complete, sending a message tells the activity that it is equivalent to asynchronous processing.

Task, simply put, is a collection of activity components that are clustered together in a stack of patterns. They have potential pre-and post-drive associations, the newly added activity component, at the top of the stack, and only activity at the top of the stack, before they have the opportunity to interact with the user. When the activity at the top of the stack completes its mission, the task will pull it out and let the next activity that will run to the top of the stack come to the user until there is no more activity,task end in the stack.

Application+handle+task

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.