We just need to set the value in this variable and get the value in any activity, even in service or broadcast receiver in the application context.
Note- Every application has a context, and Android guarantees that the application context will exist as an instance across the application.
So we just need to specify our global class in the application tag of the Android manifest file of the application.
Android will create an instance of that global class and make it available for the entire application context.
We can get the object of that global class using the following method,