Difference between getApplicationContext () and getbasecontext () and this, getbasecontext
GetApplicationContext () returns the context of the application. The life cycle is the whole application, and the application is destroyed only when it is destroyed.
The context of Activity. this returns the context of the current activity, which belongs to the activity. If the activity is destroyed, it is destroyed.
Getbasecontext () returns the context specified by the constructor or set by setBaseContext ().
GetApplicationContext () is different from Activitythis.
GetApplicationContext () returns the context of the application. The life cycle is the whole application, and the application is destroyed only when it is destroyed.
The context of Activity. this returns the context of the current activity, which belongs to the activity. If the activity is destroyed, it is destroyed.
GetBaseContext () returns the context specified by the constructor or set by setBaseContext ().
What is the difference between thisgetContext () and getApplicationContext () in android?
This. getContext () obtains the Context of the current Activity, while getApplicationContext () obtains the Context of the Application.