In my application i need to use cursor in service class. I already used the cursor in activity class, but i don't know how to use the cursor in service class. I tried that but it shows error. any one please suggest me how to use this. Thanks in advance.
service class:
public class BillTracker extends Service {
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String operatorName = tm.getSimOperatorName();
Log.v("TAG_OPERATORNAME", "" + operatorName);
if(operatorName.equalsIgnoreCase("Airtel") ) {
_Airtel_info();
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public void _Airtel_info() {
Uri qryinBox = Uri.parse("content://sms/inbox");
Cursor qryinBoxRes =context.getContentResolver().query(qryinBox, new String[]{"_id", "thread_id", "address", "person", "date", "body", "type"}, null, null, null);
context.startManagingCursor(qryinBoxRes);
// startMangingcursor showing error (cannot resolve method)
String[] columns = new String[]{"address", "person", "date", "body", "type"};
if (qryinBoxRes.getCount() > 0) {
String count = Integer.toString(qryinBoxRes.getCount());
while (qryinBoxRes.moveToNext()) {
String address = qryinBoxRes.getString(qryinBoxRes.getColumnIndex(columns[0]));
long SMSdate = qryinBoxRes.getLong(qryinBoxRes.getColumnIndex(columns[2]));
body = qryinBoxRes.getString(qryinBoxRes.getColumnIndex(columns[3]));
String name = qryinBoxRes.getString(qryinBoxRes.getColumnIndex(columns[1]));
String type = qryinBoxRes.getString(qryinBoxRes.getColumnIndex(columns[4]));
if (address.contains("+91845435435454") && SMSdate > MonthAgo) {
}
}
}
}