1. The difference between getApplication and getApplicationContext

getApplication

Is a singleton class, only one will be created;

2. It can only be used in activities and services, but cannot be used in broadcasting.

3. Obtain the application object of the entire application.

4. It exists when the application is created (assigned in onAttach);

5.UI updates do not use getApplication;

getApplicationContext

1. Obtain the Application context and regard the Application as the context.

2. The life cycle is the entire application, which will be destroyed as the application exits;


Refer to the file: stackoverflow.com/questions/5…