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

判断是否为SIM卡联系人的更多相关文章

  1. android 判断是否有sim卡及运营商

    判断是否有sim卡的方法:   int absent = TelephonyManager.SIM_STATE_ABSENT; if (1 == absent) { Log.d(TAG,"请 ...

  2. sim卡联系人name为空的问题。

    1,之前的版本出现Bug:新建name为空的sim卡联系人,无法删除. 解决: 2,而后的版本出现新Bug:新建name不为空,Num不为空的sim卡联系人,然后编辑sim卡联系人,将Name清空,无 ...

  3. Android--获取手机联系人和Sim卡联系人

    最近公司做的一个放贷APP,要求后台偷偷获取用户的联系人来做风控,所以...(大家忽略就好) 获取手机联系人很简单,就是查询android的数据库,用到的是ContentProvider进行跨进程通讯 ...

  4. android中判断sim卡状态和读取联系人资料的方法

    在写程序中,有时候可能需要获取sim卡中的一些联系人资料.在获取sim卡联系人前,我们一般会先判断sim卡状态,找到sim卡后再获取它的资料,如下代码我们可以读取sim卡中的联系人的一些信息. Pho ...

  5. 十九、android中判断sim卡状态和读取联系人资料的方法

    在写程序中,有时候可能需要获取sim卡中的一些联系人资料.在获取sim卡联系人前,我们一般会先判断sim卡状态,找到sim卡后再获取它的资料,如下代码我们可以读取sim卡中的联系人的一些信息. Pho ...

  6. android2.2应用开发之IccCard(sim卡或USIM卡)

    tyle="margin:20px 0px 0px; font-size:14px; line-height:26px; font-family:Arial; color:rgb(51,51 ...

  7. android2.2应用开发之IccCard(sim卡或USIM卡)(转至 http://www.2cto.com/kf/201306/223784.html)

    如果要做android通讯录的联系人的机卡混排显示,由于手机卡类型的不同,导致手机卡存储容量以及可以存储信息不同,就要涉及到android去读Icc卡的信息. 一般的sim卡只能存储姓名跟一个电话号码 ...

  8. android131 360 05 手势触摸滑动,sim卡,开机启动的广播,手机联系人,SharedPreferences,拦截短信

    安卓手势触摸滑动: package com.itheima52.mobilesafe.activity; import android.app.Activity; import android.con ...

  9. Android 判断SIM卡属于哪个移动运营商

    第一种方法:获取手机的IMSI码,并判断是中国移动\中国联通\中国电信 TelephonyManager telManager = (TelephonyManager) getSystemServic ...

随机推荐

  1. python接口自动化3-自动发帖(session)

    前言 上一篇模拟登录博客园,但这只是第一步,一般登录后,还会有其它的操作,如发帖,评论等,这时候如何保持会话呢? (敲黑板!!!由于博客园最近登录机制变了,登录全部走cookie登录) 一.sessi ...

  2. 使用 UIFontWDCustomLoader 载入自定义字体

    UIFontWDCustomLoader https://github.com/daktales/UIFontWDCustomLoader You can use UIFontWDCustomLoad ...

  3. MyBatis的动态SQL详解-各种标签使用

    MyBatis的动态SQL是基于OGNL表达式的,它可以帮助我们方便的在SQL语句中实现某些逻辑. MyBatis中用于实现动态SQL的元素主要有: if choose(when,otherwise) ...

  4. 前端新手如何安装webstorm ,初步搭建react项目

    下载安装webstorm:配置成功: 配置成功后就可以开启webstorm项目了.(存微信收藏..) 1:在webstorm下配置node环境: 2:完成之后: React官方脚手架地址: https ...

  5. Asp.Net Core App 部署故障示例 2

    相关阅读:Windows + IIS 环境部署Asp.Net Core App 1.  HTTP Error 502.5 – Process Failure 环境 Windows Server 201 ...

  6. scala编程第19章学习笔记(1)——类型参数化

    一.queues函数式队列 函数式队列是一种具有以下三种操作方式的数据结构: head 返回队列的第一个元素. tail 返回除第一个元素之外的队列. scala> import scala.c ...

  7. libcurl使用easy模式阻塞卡死等问题的完美解决---超时设置

    libcurl使用时疑难问题: 在使用libcurl时, jwisp发现, curl_easy_perform是阻塞的方式进行下载的, curl_easy_perform执行后,程序会在这里阻塞等待下 ...

  8. [Linux]在终端启动程序关闭终端不退出的方法

    一般情况下关闭终端时,那么在这个终端中启动的后台程序也会终止,要使终端关闭后,后台程序保持执行,使用这个指令: nohup 命令 & 如:nohup test.sh & 回车,然后提示 ...

  9. Linux 挂载和卸载U盘

    一般的U盘挂载方法: mount [-fnrsvw]  [-t vfstype] [-o options] device dir 参数:device表示要挂载的设备,dir表示挂载点 -t 指定设备的 ...

  10. 实现iframe窗口高度自适应的又一个巧妙思路

    domainA 中有一个页面index.html,通过iframe嵌套了domainB中的一个页面other.html由于other.html页面在iframe中显示,而且其页面内容会动态的增加或减少 ...