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

Android Build an Interactive Story App (Retired) Intents and Multiple Activities Adding a Second Activity

sahil shokeen
sahil shokeen
1,579 Points

Context

here when we start new activity we create object of intent class but i am not able to understand this context concept....please explain!!

3 Answers

Hello,

One of the ways I see the Context is what is holding everything, displaying it, and tracking its state. For myself, that tends to almost always be an Activity. This works since Activity is a descendent of the Context class. Your application as a whole is another context.

sahil shokeen
sahil shokeen
1,579 Points

then what is the difference b/w context class and object class???

One way to look at that is that all Contexts are Objects, but not all Objects are Contexts. For example, a View is a type of Object, but it is not a type of Context. In other words, the Context class is a descendent of the Object class. Since Activities are a descendent of the Context class, Activities are also a descendent of the Object class(in fact almost everything in Java is a descendent of the Object class).