判断是否为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;
}
}
判断是否为SIM卡联系人的更多相关文章
- android 判断是否有sim卡及运营商
判断是否有sim卡的方法: int absent = TelephonyManager.SIM_STATE_ABSENT; if (1 == absent) { Log.d(TAG,"请 ...
- sim卡联系人name为空的问题。
1,之前的版本出现Bug:新建name为空的sim卡联系人,无法删除. 解决: 2,而后的版本出现新Bug:新建name不为空,Num不为空的sim卡联系人,然后编辑sim卡联系人,将Name清空,无 ...
- Android--获取手机联系人和Sim卡联系人
最近公司做的一个放贷APP,要求后台偷偷获取用户的联系人来做风控,所以...(大家忽略就好) 获取手机联系人很简单,就是查询android的数据库,用到的是ContentProvider进行跨进程通讯 ...
- android中判断sim卡状态和读取联系人资料的方法
在写程序中,有时候可能需要获取sim卡中的一些联系人资料.在获取sim卡联系人前,我们一般会先判断sim卡状态,找到sim卡后再获取它的资料,如下代码我们可以读取sim卡中的联系人的一些信息. Pho ...
- 十九、android中判断sim卡状态和读取联系人资料的方法
在写程序中,有时候可能需要获取sim卡中的一些联系人资料.在获取sim卡联系人前,我们一般会先判断sim卡状态,找到sim卡后再获取它的资料,如下代码我们可以读取sim卡中的联系人的一些信息. Pho ...
- android2.2应用开发之IccCard(sim卡或USIM卡)
tyle="margin:20px 0px 0px; font-size:14px; line-height:26px; font-family:Arial; color:rgb(51,51 ...
- android2.2应用开发之IccCard(sim卡或USIM卡)(转至 http://www.2cto.com/kf/201306/223784.html)
如果要做android通讯录的联系人的机卡混排显示,由于手机卡类型的不同,导致手机卡存储容量以及可以存储信息不同,就要涉及到android去读Icc卡的信息. 一般的sim卡只能存储姓名跟一个电话号码 ...
- android131 360 05 手势触摸滑动,sim卡,开机启动的广播,手机联系人,SharedPreferences,拦截短信
安卓手势触摸滑动: package com.itheima52.mobilesafe.activity; import android.app.Activity; import android.con ...
- Android 判断SIM卡属于哪个移动运营商
第一种方法:获取手机的IMSI码,并判断是中国移动\中国联通\中国电信 TelephonyManager telManager = (TelephonyManager) getSystemServic ...
随机推荐
- pytest文档24-fixture的作用范围(scope)
fixture作用范围 fixture里面有个scope参数可以控制fixture的作用范围:session > module > class > function fixture( ...
- word排版汇总
1.iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库.通过iText不仅可以生成PDF或rtf 的文档,而且可以将XML.Html文件转化为PDF ...
- Android之ListView和GridVIew加载图片
清除缓存:ImageLoader 对象 . clearCache(); 使用: ImageLoader loader = new ImageLoader(ApplicationContext cont ...
- LeetCode: Implement strStr() [027]
[题目] Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if ...
- Nginx缓存使用官方教程及常见问题解答
原文地址:http://www.kuqin.com/shuoit/20150804/347388.html 我们都知道,应用程序和网站一样,其性能关乎生存.但如何使你的应用程序或者网站性能更好,并没有 ...
- eclipse svn 配置
1.安装svn http://subversion.apache.org/ 到apache网站上下载svn 2.在eclipse中安装svn插件 在eclipse->help->eclip ...
- JDBC 通过PreparedStatement 对数据库进行增删改查
1 插入数据 public boolean ChaRu3(User user){ boolean flag=true; Connection conn=null; PreparedStatement ...
- Informatica 常用组件Expression之二 创建EXP组件
在 Mapping Designer 中选择"转换-创建".选择表达式转换.为它输入一个名称(惯例为 EXP_TransformationName)并单击"确定" ...
- 第九章 Redis过期策略
注:本文主要参考自<Redis设计与实现> 1.设置过期时间 expire key time(以秒为单位)--这是最常用的方式 setex(String key, int seconds, ...
- leetcode414-第三大的数
给定一个非空数组,返回此数组中第三大的数.如果不存在,则返回数组中最大的数.要求算法时间复杂度必须是O(n). 示例 1: 输入: [3, 2, 1] 输出: 1 解释: 第三大的数是 1. 示例 2 ...