- Use this, indicating that the current class is the subclass of Context, usually the Activity Application, etc.
This: Represents the current, in Activity, it represents the current Activity.
Activity.This’s Context returns the context of the current Activity, which belongs to Activity. Activity destroys him and destroys
- Use GetApplicationContext to obtain the Application used by the current app, which is the only specified in Androidmanifest. It means that using this function at any position of the current app is the same context;
GetApplicationContext (): Back to the context of the application, the life cycle is the entire application, the application is destroyed, it is destroyed.
- Use GetContext to get the Context where the current object is located. Context is usually translated as context. I usually understand it as a scene.
- GetApplication (): Andorid develops global data in development;
- GetBaseContext () Return to context set by the constructor specified or setBaseContext ()In our usual development, sometimes some global data may be needed to allow all Activity and View to be accessed in the application. When you encounter this situation, you may first think of yourself defining a class. Then create a lot of static members, but Andorid has provided us with a solution for this situation: in Android, there is a class called Application. We can use GetApplication () in Activity. The application of the application can obtain the theme of the current application, the content of the resource file, etc. This class is more flexible that it can be inherited by us to add our own global attributes.
Reprinted from:https://www.cnblogs.com/bluestorm/p/5842891.html