Nandu
Nandu

Reputation: 31

Android Context object, Intents

Why is a Context object reference required while creating an Intent object??

Intent i = new Intent(context,Target.class);

Upvotes: 1

Views: 81

Answers (3)

Tony the Pony
Tony the Pony

Reputation: 41357

The Context contains information about the current runtime state of the app, and is vital to the processing of Intents. For example, it keeps track of the application's permissions to ensure that the app is allowed to perform the requested action.

Upvotes: 0

ngesh
ngesh

Reputation: 13501

Probably because to keep your data linked.. Intent keeps information and shares it where as Context keeps the whole Application together...

In programmers view.. Context has methods/fields which Intent needs for Object creation..

Upvotes: 1

Samir Mangroliya
Samir Mangroliya

Reputation: 40416

Context is reffred as object of Activity class so its necessary to start Another Activity from this(Context) Activity

Upvotes: 2

Related Questions