安卓手机读取双卡的通讯录

基础知识和参考资料
http://www.cnblogs.com/flyme/p/4538002.htmlhttp://blog.csdn.net/u013686019/article/details/71195230
http://blog.csdn.net/maetelibom/article/details/78051951

SubscriptionManager subscriptionManager=SubscriptionManager.from(this);
        int activeSubscriptionInfoCount = subscriptionManager.getActiveSubscriptionInfoCount();//获取装卡的卡槽数量
        List activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();//获取所有卡的集合
         int activeSubscriptionInfoCountMax = subscriptionManager.getActiveSubscriptionInfoCountMax();//最大卡槽数量
        for (SubscriptionInfo info:activeSubscriptionInfoList){
            int simSlotIndex = info.getSimSlotIndex();
            //这里就是卡槽的下标数
            //content://icc/adn/subId/0
            //后面的数值为卡槽的位置下标
            Log.e("te","卡槽"+simSlotIndex);


        }
        Log.e("te","er"+activeSubscriptionInfoCount);
        ArrayList list_one = new ArrayList<>();
        try {

            Uri uri= Uri.parse("content://icc/adn/subId/0");
            Cursor query_sim = getContentResolver().query(uri, phones_projection, null, null, null);
            if(query_sim!=null){
                while(query_sim.moveToNext()){//查询sim
                    String name = query_sim.getString(query_sim.getColumnIndex(Contacts.People.NAME));
                    String phone = query_sim.getString(query_sim.getColumnIndex(Contacts.People.NUMBER));
                    if((!TextUtils.isEmpty(phone)||(!TextUtils.isEmpty(name)))){
                        Phone_name phone_name=new Phone_name();
                        phone_name.setName(name);
                        phone_name.setPhone(phone);
                        list_one.add(phone_name);
                    }
                    //   Log.e("asw",(j+1)+"手机"+phone_name.toString()+"shouji");
                }
                query_sim.close();
            }
            Log.e("te",list_one.toString());
        }catch (Exception e){
            Log.e("ces",e.toString());
        }

你可能感兴趣的:(安卓手机读取双卡的通讯录)