判断是否为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;
    }
}

最新文章

  1. MySql in子句 效率低下优化
  2. WinForm开发框架【细化权限至操作按钮】
  3. centos下postgresql的安装与配置[转]
  4. 【Networking】gRPC golang 相关资料
  5. (转)Javascript匿名函数的写法、传参、递归
  6. Android 上千张图片的列表滑动加载
  7. DirectShow系统初级指南
  8. SPRING IN ACTION 第4版笔记-第九章Securing web applications-007-设置LDAP server比较密码(contextSource、root()、ldif()、)
  9. POJ 2886 Who Gets the Most Candies? 线段树
  10. BZOJ 3992 序列统计
  11. MPICH2在两台Ubuntu上安装(用mpd做进程管理)
  12. 用JavaScript判断横屏竖屏问题
  13. Boost Coroutine2 - stackful coroutine简介
  14. 电铸3D18K硬金 电铸易熔合金 电铸中空硬金饰品合金
  15. noip2010 引水入城 bfs+贪心
  16. 数据结构(java版)学习笔记(序章)
  17. flutter 容器
  18. L1-049. 天梯赛座位分配
  19. SQL小汇总
  20. ORA-01031: insufficient privileges 错误解决

热门文章

  1. DeDeCMS(织梦)变量覆盖0day getshell
  2. 第十九章 springboot + hystrix(1)
  3. 第十八章 springboot + thymeleaf
  4. Horspool 字符串匹配算法
  5. Cisco KVM Console无法打开
  6. Best Time to Buy and Sell Stock II leetcode java
  7. Gson 使用总结 高级用法
  8. VS2010调试技巧
  9. windows server 2008 远程桌面(授权、普通用户登录)~ .
  10. linux文件系统命令(1)---概述