内容观察者被调用,即使联系人没有改变 [英] Content observer is being called even if the Contacts are not changed
本文介绍了内容观察者被调用,即使联系人没有改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在面临一个问题,奇怪的是,我现在用的是 ContentObserver
赶在联系人的变化,但问题是,的onchange()
方法被调用,即使我没有做任何更改。这里是我的code:
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
推荐答案
的 registerContentObserver
方法接受一个布尔值 notifyForDescendents
变量,你设置为true。也许设置为false?
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. :)
这篇关于内容观察者被调用,即使联系人没有改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文