Application associated with context

Source: Internet
Author: User

In the development of application classification, almost every project will be used, it's four components of the implementation optimization, it is a global box, which may be so understandable, for example, we can application class to store some variables in other classes to access, for example, In Class A is stored in the variable Appliaction class, and then can be obtained in Class B, but the static variables are stored in the application, easy is reclaimed by the system, today is about the relationship between application and context

Take a look at the picture:

It can be seen from the graph that application is a subclass of the context,

From the Java inheritance of the relationship, the function of the subclass must be more powerful than the parent class, we will use the context object in many areas of the project, one method is passed through the method, one method is obtained by means of the control method, and the layout object that is used frequently in Android can be obtained, for example: LinearLayout , Relativelayout Framelayout, both provide the GetContext () method to get the context object, and the other is directly used in the application class,

public class Baseapplication extends application {public static baseapplication minstance; @Overridepublic void OnCreate ( {super.oncreate (); minstance = this;} public static Baseapplication Getapplication () {return minstance;}}
Since application is a subclass of the context, getting to application directly can




Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Application associated with context

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.