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