判断是否为SIM卡联系人
判断是否为SIM卡联系人
在AsyncQueryContacts类中。
private List<TxrjAccount> accounts = new ArrayList<TxrjAccount>();
private HashMap<Integer, TxrjAccount> accountMap = new HashMap<Integer, TxrjAccount>();
public AsyncQueryContacts(ContentResolver cr) {
super(cr);
initAccounts();
}
private void initAccounts() {
Cursor cursor = mContext.getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI,
new String[] {RawContacts._ID, RawContacts.ACCOUNT_NAME, RawContacts.ACCOUNT_TYPE },
null, null, null);
if (cursor != null) {
TxrjAccount account = null;
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex(RawContacts._ID));
String name = cursor.getString(cursor.getColumnIndex(RawContacts.ACCOUNT_NAME));
String type = cursor.getString(cursor.getColumnIndex(RawContacts.ACCOUNT_TYPE));
account = new TxrjAccount(id, name, type);
accounts.add(account);
accountMap.put(id, account);
}
cursor.close();
}
}
在AsyncQueryContacts.onQueryComplete()方法中。
if(contact.getPhoneList().size() == 1){
contact.setbSim(accountMap.get(phone.getRawContactId()).isSimAccount());
}
在TxrjAccount类中。
public static final String PHONE_ACCOUNT_NAME = "vnd.sec.contact.phone";
public static final String PHONE_ACCOUNT_TYPE = "vnd.sec.contact.phone";
public static final String SIM2_ACCOUNT_NAME = "primary.sim2.account_name";
public static final String SIM2_ACCOUNT_TYPE = "vnd.sec.contact.sim2";
public static final String SIM_ACCOUNT_NAME = "primary.sim.account_name";
public static final String SIM_ACCOUNT_TYPE = "vnd.sec.contact.sim";
public boolean isSimAccount() {
if(type.equals(SIM_ACCOUNT_TYPE) || type.equals(SIM2_ACCOUNT_TYPE)) {
return true;
} else {
return false;
}
}
最新文章
- MySql in子句 效率低下优化
- WinForm开发框架【细化权限至操作按钮】
- centos下postgresql的安装与配置[转]
- 【Networking】gRPC golang 相关资料
- (转)Javascript匿名函数的写法、传参、递归
- Android 上千张图片的列表滑动加载
- DirectShow系统初级指南
- SPRING IN ACTION 第4版笔记-第九章Securing web applications-007-设置LDAP server比较密码(contextSource、root()、ldif()、)
- POJ 2886 Who Gets the Most Candies? 线段树
- BZOJ 3992 序列统计
- MPICH2在两台Ubuntu上安装(用mpd做进程管理)
- 用JavaScript判断横屏竖屏问题
- Boost Coroutine2 - stackful coroutine简介
- 电铸3D18K硬金 电铸易熔合金 电铸中空硬金饰品合金
- noip2010 引水入城 bfs+贪心
- 数据结构(java版)学习笔记(序章)
- flutter 容器
- L1-049. 天梯赛座位分配
- SQL小汇总
- ORA-01031: insufficient privileges 错误解决
热门文章
- DeDeCMS(织梦)变量覆盖0day getshell
- 第十九章 springboot + hystrix(1)
- 第十八章 springboot + thymeleaf
- Horspool 字符串匹配算法
- Cisco KVM Console无法打开
- Best Time to Buy and Sell Stock II leetcode java
- Gson 使用总结 高级用法
- VS2010调试技巧
- windows server 2008 远程桌面(授权、普通用户登录)~ .
- linux文件系统命令(1)---概述