1

我想知道电话管理器在Android平台上可以测量多少个GSM参数?代码示例将不胜感激。

4

2 回答 2

2

首先,您应该查看官方文档http://developer.android.com/reference/android/telephony/PhoneStateListener.html

可供开发人员使用的 GSM 参数并不多,例如国家代码、rssi,但没有带下划线的参数。

private void getNWInfo(Context context) {
      /**
       * <uses-permission android:name="android.permission.READ_PHONE_STATE"
       * /> <uses-permission
       * android:name="android.permission.ACCESS_NETWORK_STATE"/>
       */

      TelephonyManager telephonyManager = (TelephonyManager) context
                   .getSystemService(Context.TELEPHONY_SERVICE);
      String networkOperator = telephonyManager.getNetworkOperator();
      int mcc = 0, mnc = 0;
      if (networkOperator != null) {
             mcc = Integer.parseInt(networkOperator.substring(0, 3));
             mnc = Integer.parseInt(networkOperator.substring(3));
      }

      String SimNumber = telephonyManager.getLine1Number();

      String SimSerialNumber = telephonyManager.getSimSerialNumber();
      String countryISO = telephonyManager.getSimCountryIso();
      String operatorName = telephonyManager.getSimOperatorName();
      String operator = telephonyManager.getSimOperator();
      int simState = telephonyManager.getSimState();

      String voicemailNumer = telephonyManager.getVoiceMailNumber();
      String voicemailAlphaTag = telephonyManager.getVoiceMailAlphaTag();

      // Getting connected network iso country code
      String networkCountry = telephonyManager.getNetworkCountryIso();
      // Getting the connected network operator ID
      String networkOperatorId = telephonyManager.getNetworkOperator();
      // Getting the connected network operator name
      String networkName = telephonyManager.getNetworkOperatorName();

      int networkType = telephonyManager.getNetworkType();

      String network = "";
      ConnectivityManager cm = (ConnectivityManager) context
                   .getSystemService(Context.CONNECTIVITY_SERVICE);
      try {
             if (cm.getActiveNetworkInfo().getTypeName().equals("MOBILE"))
                   network = "Cell Network/3G";
             else if (cm.getActiveNetworkInfo().getTypeName().equals("WIFI"))
                   network = "WiFi";
             else
                   network = "N/A";
      } catch (Exception e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
      }

      TextView  textView = (TextView) findViewById(R.id.textView);
      textView.setText("network :" + network +

      "\n" + "countryISO : " + countryISO + "\n" + "operatorName : "
                   + operatorName + "\n" + "operator :      " + operator + "\n"
                   + "simState :" + simState + "\n" + "Sim Serial Number : "
                   + SimSerialNumber + "\n" + "Sim Number : " + SimNumber + "\n"
                   + "Voice Mail Numer" + voicemailNumer + "\n"
                   + "Voice Mail Alpha Tag" + voicemailAlphaTag + "\n"
                   + "Sim State" + simState + "\n" + "Mobile Country Code MCC : "
                   + mcc + "\n" + "Mobile Network Code MNC : " + mnc + "\n"
                   + "Network Country : " + networkCountry + "\n"
                   + "Network OperatorId : " + networkOperatorId + "\n"
                   + "Network Name : " + networkName + "\n" + "Network Type : "
                   + networkType);

}

在此处查找更多信息

于 2014-08-17T11:32:50.773 回答
0

和谐,万一你不知道。高通(或芯片背后的公司)不会免费开放任何东西。是的,跟踪并收集有关您的手机与 NodeB 或 BTS 之间对话的 L3 信息很容易,但这是不可能的,或者您需要特殊的手机并支付大量美元。

于 2017-11-01T16:50:56.487 回答