juniorAndroid
What is Android Application Context vs Activity Context?
Updated Apr 28, 2026
Short answer
Application Context lives as long as the app, while Activity Context is tied to an Activity lifecycle.
Deep explanation
In Android, Context provides access to application resources and services. Application Context is global and survives as long as the app process exists, while Activity Context is tied to UI lifecycle. Using the wrong context can lead to memory leaks, especially when Activity Context is retained beyond its lifecycle.
Real-world example
Using Application Context for initializing libraries and Activity Context for UI operations like dialogs.
Common mistakes
- Using Activity context in long-lived objects causing memory leaks.
Follow-up questions
- When should you use Application Context?
- Why avoid Activity Context in static objects?