I registered the ContentObserver service from the service, and I get the onchange() function when there is an update in the phone, for example, when I call or update a contact. But I want the onchange() function to onchange() called only when an add, update or delete occurs. But I do not want an incoming or outgoing call to be called. So can someone tell me which URI I can register with ContentObserver ? My code is here
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true,new Contact_change());
and the Contact_change.java class is similar to
public class Contact_change extends ContentObserver{ public Contact_service() { super(null); } @Override public void onChange(boolean selfChange){ Log.i("contact_service","onchange"); Super.onChange(selfChange); } @Override public boolean deliverSelfNotifications() { return true; } }
Edit:
I have one more problem: after stopping the service, if I change the contact, the onchange() function is also called. So how can I stop this or register a ContentObserver .
Nency
source share