Basic Examples

suggest change

Standard usage in Activity:

Context context = getApplicationContext();

Standard usage in Fragment:

Context context = getActivity().getApplicationContext();

this can be used as a Context when the class extends Context, such as Application, Activity, Service, and IntentService:

TextView textView = new TextView(this);

Another this example:

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

Feedback about page:

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



Table Of Contents