Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Ebrahim Haji
6,712 PointsWhat is Context
i need someone to explain it because i dont get it.
1 Answer
Ben Jakuben
Treehouse TeacherThe context in Android is hard to get because it's kind of abstract. It basically represents the current context that your app is operating in. Usually it refers to an Activity, because often our apps are running code within an Activity (or within an object being used by the Activity).
Here's a quick answer from the Teacher Notes section of the Toast Notifications video in the Crystal Ball project:
Context - In Android, the Context is the current state of the application (or object). It's important because oftentimes an object or method will need to know the current context to behave appropriately. In an Activity class, the context can usually be represented using the this keyword because this refers to the current class, and Activities are children of the Context class. This means that Activities can also represent the current context.