BroadcastReceiver 用于在收藏夹/注视中添加或删除联系人时收听
Posted
技术标签:
【中文标题】BroadcastReceiver 用于在收藏夹/注视中添加或删除联系人时收听【英文标题】:BroadcastReceiver to listen when a contact added or deleted from favorite/stared 【发布时间】:2016-08-05 13:39:41 【问题描述】:在收藏夹/已加星标的联系人列表中添加/删除联系人时,是否有办法收听/处理。
我已经检查了onChange()
。但它不处理收藏夹/加星标设置。
【问题讨论】:
【参考方案1】:有一个默认的联系观察者..希望对你有帮助
public class MyCOntentObserver extends ContentObserver
public MyCOntentObserver()
super(null);
@Override
public void onChange(boolean selfChange)
super.onChange(selfChange);
final int currentCount = getContactCount();
// Get count from your sqlite database
int mContactCount = getContactOWNCount();
if (currentCount < mContactCount)
// DELETE HAPPEN.
Log.e("Status", "Deletion");
//contactDBOperaion.SyncContacts(1);
else if (currentCount == mContactCount)
// UPDATE HAPPEN.
// contactDBOperaion.SyncContacts(0);
else
// INSERT HAPPEN.
Log.e("Status", "Insertion");
// contactDBOperaion.SyncContacts(2);
Log.e("", "~~~~~~" + selfChange);
@Override
public boolean deliverSelfNotifications()
return true;
【讨论】:
以上是关于BroadcastReceiver 用于在收藏夹/注视中添加或删除联系人时收听的主要内容,如果未能解决你的问题,请参考以下文章
用于 Google 云消息传递客户端的 BroadcastReceiver 或 GCMBroadcastReceiver?
BroadcastReceiver,用于在基于 Samsung-Android 的智能手机上接收短信