tags:

views:

848

answers:

2

using registerContentObserver() to be notified as the contacts are changed,but when i register for the content uri:People.CONTENT_URI and when i observe in the log cat i'm getting the notify as "false" even after changing the contact. i have also over ridden the deliverSelfNotification to true. can u help me out with this Thank you

A: 

Not sure what your asking, your question is a bit vague.

Here is how I listen out for changes in the SMS content provider, you may find it useful

String url = "content://sms/"; 
        Uri uri = Uri.parse(url); 
        getContentResolver().registerContentObserver(uri, true, new MyContentObserver(handler)); 

        /uriSms = Uri.parse("content://sms/inbox");
        Cursor c = getContentResolver().query(uriSms, null,null,null,null); 

        //Log.d("COUNT", "Inbox count : " + c.getCount());


}

class MyContentObserver extends ContentObserver { 

    public MyContentObserver(Handler handler) { 

        super(handler); 

    }

@Override public boolean deliverSelfNotifications() { 
    return false; 
    }

@Override public void onChange(boolean arg0) { 
    super.onChange(arg0);

     Log.v("SMS", "Notification on SMS observer"); 

    Message msg = new Message();
    msg.obj = "xxxxxxxxxx";

    handler.sendMessage(msg);

    Uri uriSMSURI = Uri.parse("content://sms/");
    Cursor cur = getContentResolver().query(uriSMSURI, null, null,
                 null, null);
    cur.moveToNext();
    String protocol = cur.getString(cur.getColumnIndex("protocol"));
    if(protocol == null){
           Log.d("SMS", "SMS SEND"); 
           int threadId = cur.getInt(cur.getColumnIndex("thread_id"));
           Log.d("SMS", "SMS SEND ID = " + threadId); 
           getContentResolver().delete(Uri.parse("content://sms/conversations/" + threadId), null, null);

    }
    else{
        Log.d("SMS", "SMS RECIEVE");  
         int threadIdIn = cur.getInt(cur.getColumnIndex("thread_id"));
         getContentResolver().delete(Uri.parse("content://sms/conversations/" + threadIdIn), null, null);
    }

}
Donal Rafferty
O.k i will be more clear: I have my own address book application for which i am fetching the contact Name and contact Number form the native address book using the contact content provider. So my question is: 1) How do i get a notify for my application when the Contact Name or Contact Number of a particular person is changed in the native address book 2) How do i get to know which field in the native address book has been changed. Thank you
warrior
A: 

hi, could you please tell how can me do this exact thing for the CallLog.Call s???

MIke