i have service s contains thread t. have java class c. call method of class c thread t. method supposed contain lines :
uri uri = uri.parse("content://sms"); cursor cursor1 = getcontentresolver().query(uri, null, null ,null, null);
the problem error " cannot resolve methode 'getcontentresolver()' ". know matter of context, don't know how solve it.
edit
without considering thread t, tried :
the class c :
public class sms { private arraylist<string> smslist = new arraylist<>(); public sms(context context){ uri uri = uri.parse("content://sms"); cursor cursor1 = context.getcontentresolver().query(uri, null, null ,null, null); } }
the service s :
public class myservice extends service{ sms sms = new sms(this); }
but error :
java.lang.nullpointerexception @ com.example.maxime.servicesms2.sms.<init>(sms.java:18)
line 18 being :
cursor cursor1 = context.getcontentresolver().query(uri, null, null ,null, null);
thank !
you can make service child of android.app.service
public class services extends service {...}
then have getcontentresolver() method
Comments
Post a Comment