Basic Examples

suggest change

Standard usage in Activity:

Context context = getApplicationContext();

Standard usage in Fragment:

Context context = getActivity().getApplicationContext();

this (when in a class that extends from Context, such as the Application, Activity, Service and IntentService classes)

TextView textView = new TextView(this);

another this example:

Intent intent = new Intent(this, MainActivity.class);

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents