Basic Examples
suggest changeStandard 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);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents