android - the method getApplicationContext() is undefined -
public void onproviderdisabled(string provider) { toast.maketext(getapplicationcontext(), "gps disabled", toast.length_short); } so have, , shows error , tells me method getapplicationcontext() undefined type mylocationlistener
what should avoid error
since aren't in activity need pass context class. wherever instantiate class pass activities context
myclass myclass = new myclass(this); then create constructor in class accepts context param , use that
public class myclass { context c; public myclass(context context) { c = context; } } then when need use it
public void onproviderdisabled(string provider) { toast.maketext(c, "gps disabled", toast.length_short); }
Comments
Post a Comment