Ok, I will give a small example on how to do what you ask
public class ClassB extends Activity
{
ClassA A1 = new ClassA(this); // for activity context
ClassA A2 = new ClassA(getApplicationContext()); // for application context.
}
More Related Contents:
- What is ‘Context’ on Android?
- When to call activity context OR application context?
- Static way to get ‘Context’ in Android?
- Difference between getContext() , getApplicationContext() , getBaseContext() and “this”
- Using Application context everywhere?
- What’s the difference between the various methods to get an Android Context?
- Difference between Activity Context and Application Context
- Dialog throwing “Unable to add window — token null is not for an application” with getApplication() as context
- How to get package name from anywhere?
- Calling startActivity() from outside of an Activity context
- What’s “tools:context” in Android layout files?
- Using getResources() in non-activity class
- Android : Static Fields and Memory Leaks
- getApplicationContext(), getBaseContext(), getApplication(), getParent()
- getting context in AsyncTask
- How can I share a SharedPreferences file across two different android apps?
- Why does AlertDialog.Builder(Context context) only accepts Activity as a parameter?
- get Context in non-Activity class [duplicate]
- Get context inside onClick(DialogInterface v, int buttonId)?
- Call getLayoutInflater() in places not in activity
- Android: why must use getBaseContext() instead of this
- Dagger 2 injecting Android Application Context
- Android Get Application’s ‘Home’ Data Directory
- How to call getResources() from a class which has no context?
- Diffinitive rules for using Android’s getBaseContext, getApplicationContext or using an Activity’s “this”
- Android: ProgressDialog doesn’t show
- Android : References to a Context and memory leaks
- Getting the Application Context
- Use of Context to start another Activity
- android – How to get view from context?