What is the difference between an Activity Context and an Application Context?

The Activity Context is created when an activity is created and is destroyed when the activity is destroyed. Since context is a heavy object, when memory leaks are mentioned in Android, they often refer to context leaks. This happens when the context of an activity is retained after Activity.onDestroy() has been called. To avoid this, do not pass the Activity Context to another object if the lifecycle of that object is unknown or if it might outlive the activity. More information on memory leaks.

On the other hand, the Application Context is a singleton. It is created when the Application object is created and remains alive as long as the application’s process is running. This makes the Application Context safe to inject into other singletons within the application. However, it is generally not recommended to use the Application Context for starting activities, as it may require creating a new task, or for layout inflation, since it applies the default theme instead of the activity-specific one.