How to reference the current or main activity from another class

If you already have a valid context, just use this: Activity activity = (Activity) context;


Passing context is better way for refrence Activity.

You can pass Context to another class.

IN Activity ::

AnotherClass Obj  = new AnotherClass(this);

IN Another Class

class AnotherClass{

public AnotherClass(Context Context){

    }

}