Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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).