If you are running a method that needs a context, and that method is running in a class that is extended from Activity, then you can get the context of that activity by declaring a variable for that activity, and then in your onCreate method do -> activity=this;
i,e
Activity activity;
//this is globally declared
And inside onCreate do activity=this;
void onCreate(Bundle savedInstanceState)
{
....
activity=this;
....
}
Now you are having the context of your current activity in "activity" variable.You can use this inside your method or pass it as a parameter or whatever you want... And if you are having the method that is not in an Activity class, then you should call it by passing this "activity" variable to that method.