What is the actual differences between a activity context and application context?

Technology CommunityCategory: AndroidWhat is the actual differences between a activity context and application context?
VietMX Staff asked 3 years ago

They are both instances of Context, but the application instance is tied to the lifecycle of the application, while the Activity instance is tied to the lifecycle of an Activity. Thus, they have access to different information about the application environment.

If you read the docs at getApplicationContext it notes that you should only use this if you need a context whose lifecycle is separate from the current context.

In general, use the activity context unless you have a good reason not to.