Reputation: 247
I am using method Window wingdow = getWindow()
in my Activity
class. Now i want to use this method in simple java class but it get errors not resolve method
. I also use contex
t but it also get erros. How can we access it in simple java class.
Upvotes: 2
Views: 1594
Reputation: 8562
Create instance passing Activity
as parameter of constructor
MyClass myClass= new MyClass(this);
And use getWindow()
method like here
public Class MyClass
{
public Activity activity;
public MyClass(Activity act)
{
this.activity = act;
}
public void otherMethod(){
Window window = act.getWindow()
}
}
Upvotes: 4