1. I'm beginning to not understand why the explicit intent of this (current activity) is. Because the intent inside of the construction method corresponds to the Context, Class. We found the data back.
New Intent (This, anotheraty. Class); // called in activity.
Public Intent (Context packagecontext, class<?> cls) { new componentname (Packagecontext, CLS); }
It is because the activity has inherited the android.content.Context. Here is the official explanation.
An interface for global information about the application environment. This is an abstract class, and its implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as application-level actions such as initiating activities, calling, broadcasting and receiving intentions, and so on.
In fact, the text is the context, you can get global resources. (just learned here, other methods can be used to check the manual)
this. getresources (). getString ("App_name"); // The activity call can get the value defined by the global app_name
2. Android.app.Application class
A base class that needs to maintain global application state. You can provide your own implementation by specifying its name in your androidmanifest.xml. XML <application> tags, which will cause this class to be instantiated when you create the process for your application/package.
For example, if you define a global class and the app inherits the application , you'll set android:name= in the XML <application> tag. App "
This allows you to share the app class with all your activity. in fact, each activity also inherits this application class. The application class also inherits the context class
App app = (APP)this. Getapplicationcontext (); There must be a getresources () method in the activity call.
PS: Just learn, record a little. Have a better experience in the future in the update
The relationship between Android Context and application