电话管理器gsm参数

时间:2014-08-17 11:16:57

标签: android gsm android-wireless

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

2 个答案:

答案 0 :(得分:1)

首先,您应该查看官方文档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);

}

查找更多信息here

答案 1 :(得分:0)

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