【问题标题】:Get IMEI of both sim slots in dual sim android mobile devices获取双卡安卓移动设备中两个 sim 卡插槽的 IMEI
【发布时间】:2014-03-11 21:15:06
【问题描述】:

我正在为双卡手机创建一个应用程序。该应用程序应该能够检测到用户通过其拨打电话的 SIM 卡。它可以是呼出或呼入。我尝试使用this tutorial 获取设备的两个IMEI 号码。但是第二个 IMEI 号返回 null。

我必须如何检测用户在拨打或接听电话时使用的是哪个 SIM 卡。

请提出任何方法来实现这一点。

【问题讨论】:

  • @Pied Piper 请调查这个问题。
  • 好吧,双 sim 卡实现是 OEM 特定的,并且设计因供应商而异。您需要使用反射来找到可以返回模拟数据的确切类。试错是一种方式
  • [获取双卡安卓移动设备中两个卡槽的IMEI][1] [1]:stackoverflow.com/questions/14517338/…

标签: java android imei dual-sim


【解决方案1】:

在控制台中查看 SIM1 类型的状态:

adb shell dumpsys telephony.registry

在控制台中查看 SIM2 类型的状态:

adb shell dumpsys telephony.registry2

mCallState 在呼入/呼出时更改。它可以让您知道用于通话的 SIM 卡

当您从 Java 应用程序调用 dumpsys 时,您需要在清单中使用 android.permission.DUMP。但它不适用于某些新设备(它们因“Permission Denial”而失败)。

【讨论】:

    【解决方案2】:

    这可能会给你两个具有双 sim 卡的手机的 imei。

        public static void samsungTwoSims(Context context) {
    TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    
    try{
    
        Class<?> telephonyClass = Class.forName(telephony.getClass().getName());
    
        Class<?>[] parameter = new Class[1];
        parameter[0] = int.class;
        Method getFirstMethod = telephonyClass.getMethod("getDefault", parameter);
    
        Log.d(TAG, getFirstMethod.toString());
    
        Object[] obParameter = new Object[1];
        obParameter[0] = 0;
        TelephonyManager first = (TelephonyManager) getFirstMethod.invoke(null, obParameter);
    
        Log.d(TAG, "Device Id: " + first.getDeviceId() + ", device status: " + first.getSimState() + ", operator: " + first.getNetworkOperator() + "/" + first.getNetworkOperatorName());
    
        obParameter[0] = 1;
        TelephonyManager second = (TelephonyManager) getFirstMethod.invoke(null, obParameter);
    
        Log.d(TAG, "Device Id: " + second.getDeviceId() + ", device status: " + second.getSimState()+ ", operator: " + second.getNetworkOperator() + "/" + second.getNetworkOperatorName());
    } catch (Exception e) {
        e.printStackTrace();
    }   
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-08
      • 1970-01-01
      • 1970-01-01
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      • 2012-08-06
      • 1970-01-01
      相关资源
      最近更新 更多