I am just curious as to what the code below does? I am learning about Intents at the moment.
Intent i = new Intent(v.getContext(), Viewmap.class);
Am I right to think that this is creating an Intent object that will start up the Viewmap class and the getContext() method will inform the Viewmap class of where the intent came from?? I guess I’m more confused as to what v.getContext is actually doing. (v is View object).
It creates an
Intentwhich is launched from theContextcontainingv. ThisIntent‘s target isViewmap‘s class (which should be anActivityregistered in the manifest, in this case).Close. The
Contextyou provide notifies the system which package to find theViewmapclass in.It is just returning the
Contextthrough whichvis implemented. TheContextcontains things like package name, resource identifiers, and so on. The documentation describes it as an “[i]nterface to global information about an application environment. … It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.“.