The Android: Name attribute is used to set which application belongs to all activities. The default value is Android. App. application.
You can also define a class by yourself, for example:
Public class testapplication extends application {}
The function of this class is to put some global variables and methods used in the context.
Then add the Android: Name attribute to the <application/> node in androidmanifest. xml.
<Application Android: icon = "@ drawable/icon"
Android: Label = "@ string/app_name" Android: Name = ". testapplication">
In this way, we can set the default application to our custom testapplication.
The benefit of this solution is that, if an application exits, its lifecycle also ends,
If a static class is used, the program will not be recycled by GC immediately after exiting. When you enter the static class again, you will find the information saved by the static class.
Yes. The program may not be initialized as you want.
PS: testapplication must specify that the class field is public. Otherwise, an error will be reported during running and this class cannot be found.
Even if it is written as follows: Class testapplication extends application {}
No, because it is only visible to the package by default.