没有获得sim信息

时间:2012-06-30 06:30:58

标签: android wifi sim-card telephonymanager

在我的应用程序中,我使用simState == TelephonyManager.SIM_STATE_ABSENT检查Sim是否存在。如果Sim存在,我正在收集所有Sim信息,如Sim操作员名称,Sim国家等。如果我关闭WiFi,我会让Sim缺席,即使它存在,我也没有得到任何Sim详细信息。(电话经理不访问sim当wifi没有连接时。)

  1. 当WiFi关闭时,有没有其他方法可以获取Sim信息。
  2. TelephonyManager telephonyManager =
      ((TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE));
    int simState = telephonyManager.getSimState();
    if (simState == TelephonyManager.SIM_STATE_ABSENT){
            Log.d("hello", "network disconnected"); 
            operatorParam.add("Not found");
            operatorParam.add("Not found");
            operatorParam.add("Not found");
            operatorParam.add("Not found");
            operatorParam.add("Not found");
            operatorParam.add("Not found");
    
        } else {
    
            Log.d("hello", "network connected");
            if (telephonyManager.getNetworkOperatorName() != null) {
                operatorParam.add(telephonyManager.getNetworkOperatorName());
                Log.d("operator", "getoperator name not null: "
                        + telephonyManager.getNetworkOperatorName());
    
            } else {
                operatorParam.add("Not found");
            }
    
            if (telephonyManager.getSimOperatorName() != null) {
                operatorParam.add(telephonyManager.getSimOperatorName());
            } else {
                operatorParam.add("Not found");
            }
    
            if (telephonyManager.getSimOperator() != null) {
                operatorParam.add(telephonyManager.getSimOperator());
            } else {
                operatorParam.add("Not found");
            }
    
            if (telephonyManager.getSimSerialNumber() != null) {
                operatorParam.add(telephonyManager.getSimSerialNumber());
            } else {
                operatorParam.add("Not found");
            }
    
            if (telephonyManager.getSimCountryIso() != null) {
                operatorParam.add(telephonyManager.getSimCountryIso());
            } else {
                operatorParam.add("Not found");
            }
    
            if (telephonyManager.getSubscriberId() != null) {
                operatorParam.add(telephonyManager.getSubscriberId());
            } else {
                operatorParam.add("Not found");
            }
    
    
           }
    

    提前感谢。

0 个答案:

没有答案