查询方法:

public static JSONArray getAllSimInfo(TelephonyManager tel) throws Exception {    Class<?> clazz = tel.getClass();    //获取可以进行反射的字段    List list = new ArrayList<>();    Map listIgnore = new HashMap<>();    Method[] methods = clazz.getDeclaredMethods();    for(Method method : methods) {        String name = method.getName();        if(!name.startsWith("get"))            continue;        if(listIgnore.get(name) != null)            continue;        listIgnore.put(name, 0);        Method m1 = null;        Method m2 = null;        Method m3 = null;        try {m1 = clazz.getDeclaredMethod(name); } catch(Exception e) {}        try {m2 = clazz.getDeclaredMethod(name, int.class); } catch(Exception e) {}        try {m3 = clazz.getDeclaredMethod(name, long.class); } catch(Exception e) {}        if(m1 != null && ((m2 == null && m3 != null) || (m2 != null && m3 == null))) {            Class<?> c1 = m1.getReturnType();            Class<?> c2 = m2 == null ? null : m2.getReturnType();            Class<?> c3 = m3 == null ? null : m3.getReturnType();            if(m2 == null) {                if(c1 == null || c1 != c3)                    continue;            } else {                if(c1 == null || c1 != c2)                    continue;            }            EMethod item = new EMethod(name, m2 == null ? 1 : 0, c1);            list.add(item);        }    }    listIgnore.clear();    JSONArray array = new JSONArray();    for(int i=0; i<10; i++) {        JSONObject json = new JSONObject();        for(EMethod em : list) {            Method method = null;            Object param = null;            if(em.type == 0) {                method = clazz.getDeclaredMethod(em.name, int.class);                param = i;            } else {                method = clazz.getDeclaredMethod(em.name, long.class);                param = new Long(i);            }            if(!method.isAccessible())                method.setAccessible(true);            String name = em.name.substring(3);            Object value = null;            try {                value = method.invoke(tel, param);            } catch(Exception e) {                //前面已经对private设置了可访问,有些还是会报错,就不管这个了                continue;            }            json.put(name, value);        }        if(json.optInt("SimState") == TelephonyManager.SIM_STATE_UNKNOWN || json.optInt("SimState") == TelephonyManager.SIM_STATE_ABSENT)            continue;        String imsi = json.optString("SubscriberId");        if(imsi == null || imsi.length() == 0)            continue;        //根据imsi去重        boolean repeact = false;        for(int j=0; j

 

以下是查询出所有的信息:

{
    "NetworkTypeName":"UNKNOWN",
    "PhoneId":0,
    "PhoneType":1,
    "PhoneTypeFromNetworkType":1,
    "PhoneTypeFromProperty":1,
    "SubId":0,
    "CallState":0,
    "CdmaEriIconIndex":-1,
    "CdmaEriIconMode":-1,
    "CdmaEriText":"GSM nw, no ERI",
    "CurrentPhoneType":1,
    "DataNetworkType":13,
    "DeviceId":"865098038283330",
    "DeviceSoftwareVersion":"00",
    "EmergencyCallbackMode":false,
    "GroupIdLevel1":"ff",
    "Imei":"865098038283330",
    "Line1AlphaTag":"@@@@@@@@@@@@@@",
    "Line1Number":"+8613293849943",
    "LteOnCdmaMode":1,
    "Meid":"99001069328499",
    "Msisdn":"+8613293849943",
    "NetworkCountryIso":"cn",
    "NetworkOperator":"46001",
    "NetworkOperatorName":"中国联通",
    "NetworkType":13,
    "SimCountryIso":"cn",
    "SimOperator":"46001",
    "SimOperatorName":"中国联通",
    "SimOperatorNumeric":"46001",
    "SimSerialNumber":"83860112012832486267",
    "SimState":5,
    "SubscriberId":"460012889988497",
    "VoiceMailAlphaTag":"语音信箱",
    "VoiceMessageCount":0,
    "VoiceNetworkType":13
}

 

其中 Msisdn 跟 Line1Number 这两个是手机号码   SubId是卡槽id   卡1为0  卡2为1  

更多相关文章

  1. google地图demo
  2. Android(安卓)DownloadManager下载状态查询(2)
  3. ContentProvider单元测试
  4. Android(安卓)Contacts的使用(二)
  5. Android之Sqlite模糊查询
  6. 打造android ORM框架opendroid(六)——级联查询
  7. Android下实现获取本机存储的联系人
  8. android ContentResolver 多表联合查询
  9. 如何区别Android手机卡三大运营商

随机推荐

  1. android应用程序中获取view的位置(2)
  2. Android(安卓)ViewPager 小圆点指示器
  3. Android(安卓)TabWidget底部显示效果
  4. Android(安卓)MediaScannerService源码分
  5. android 指定组件的圆角图片处理
  6. android 在surfaceView上画图
  7. 《第一行代码Android》学习总结第十章 Se
  8. Android(安卓)源码编译make的错误处理
  9. 如何给android studio加速(加快gradle bui
  10. android的两种启动service方式及混合方式