Differences between this, getApplicationContext (), and getApplication () in Android, getapplication
This: indicates the current Activity, which represents the current Activity, in other words, Activity. this can be abbreviated as this in Activity.
GetApplicationContext (): the entire application lifecycle is destroyed only when the application is destroyed.
GetApplication (): share global data in andorid development;
During our normal development, we may sometimes need some global data to make all the activities and views in the application accessible. In this case, you may first think of defining a class and then creating many static members. However, andorid provides us with a solution for this situation: in Android, there is a class named Application, we can use getApplication () in the Activity to obtain it. It represents the class of our application. We can use it to obtain the topic of the current application and content in the resource file, A more flexible feature of this class is that it can be inherited by us to add our own Global attributes.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.