java - Android how to call MainActivity method from Non Activity class -
i troubing on runtime permission method in non activity class. want call public mainactivity
method helper class.
mainactivity.java method
public void a(){ //some method }
now helper class:
class b{ private context mcontext; public b(context context){ this.mcontext = context; //now calling mainactivity method mainactivity mainactivity = new mainactivity(); mainactivity.a(); } }
calling b class cactivity
oncreate(){ b b = new b(this); }
but gives me runtime error
update:
my method has runtime permission method isn't static . ex- requestpermissions(), onrequestpermissionsresult()
make method static can call without creating class object
eg
public static void testing() {}
now calling
mainactivity.testing();
Comments
Post a Comment