问题
I am facing a problem that is strange, i am using the ContentObserver
to catch the changes in the contacts, but the problem is that the onchange()
method is called even if i am not making any changes. Here is my code :
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, new MyCOntentObserver());
public class MyCOntentObserver extends ContentObserver{
public MyCOntentObserver() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Log.e("","~~~~~~"+selfChange);
}
@Override
public boolean deliverSelfNotifications() {
Log.e("","~~~~~~ Change");
return true;
}
}
any one can help?
thanks in advance
回答1:
The registerContentObserver
method accepts a boolean notifyForDescendents
variable, which you're setting to true. Maybe set that to false?
Otherwise maybe some background task is messing with your observer. :)
来源:https://stackoverflow.com/questions/10718181/content-observer-is-being-called-even-if-the-contacts-are-not-changed