android - How to reference the current or main activity from another class -


i find myself needing access methods require referencing activity. example, use getwindowmanager, need access activity. code using these methods in other class has no reference activity. until now, i've either stored reference main activity or passed context of activity class. there better way this?

passing context better way refrence activity.

you can pass context class.

in activity ::

anotherclass obj  = new anotherclass(this); 

in class

class anotherclass{  public anotherclass(context context){      }  } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -