Reputation: 31
Why should we include context object reference in the constructor while creating the Intent Object??
Example:
Intent i = new Intent(context object,Target.class);
Upvotes: 1
Views: 142
Reputation: 20875
It is used to initialize a field of type ComponentName
, which in turn is used for routing purposes across the whole API. Usage of ComponentName
seems related to the deepest (native) parts of the Android platform
Upvotes: 1
Reputation: 41510
It is required to determine the application package. Internally Intent
creates an instance of android.content.ComponentName
. While this can be achieved by specifying the package using a String
, it is easier to just specify the context.
Upvotes: 1