I start a service that registers ContentObserver
on the SMS inbox
like so
smsObserver = new SmsObserver(new Handler());
getContentResolver().registerContentObserver(Uri.parse("content://sms/inbox"), true, smsObserver);
Here is the class, I just want to know when a change is made to the provider But I dont get the callback to the onChange
method
private class SmsObserver extends ContentObserver{
public SmsObserver(Handler handler) {
super(handler);
}
@Override
public void onChange(boolean selfChange){
super.onChange(selfChange);
Cursor c = getContentResolver().query(Uri.parse("content://sms/inbox"),
new String[] {"thread_id"},"address" + "=" + from,null,null);
if(c != null && c.moveToLast()){
long id = c.getLong(0);
Log.d("ID", c.getString(0));
}
c.close();
}
}
I also register an observer for the Uri content://mms-sms/conversations
and that one works and I just copied how I did everything from this one over to the SmsObserver class so I dont know whats wrong, can I not set an observer on the content://sms/inbox
?