2013-11-28 62 views
4

有人知道如何在android中获取GSM信息吗?诸如BCCH(广播控制信道)和BCIS(基站标识码)之类的信息。我已经获得了LAC(位置区号)和CID(小区ID)。我知道这是一个低级别的信息,但有人知道获得这些信息?我很难研究,我对蜂窝网络一无所知。请帮助谢谢:)Android中的GSM网络信息

回答

3

这里是功能,它给你的GSM网络的完整信息。 只是情境呼叫从活动

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); 


    } 

你可以找到这个博客

http://khurramitdeveloper.blogspot.in/search?updated-max=2013-11-07T03:23:00-08:00&max-results=7

希望它会帮助你:)

+1

怎么样BCCH和BSIC?你有想法来检索这些信息吗? – GummyBear0014

+0

请通过这个线程https://groups.google.com/forum/#!topic/android-platform/tVyNMnXtcEI – khurram

+0

你和anchit有相同的答案。 :(请问网络的低级别信息是不是真的可能检索到? – GummyBear0014

2

请访问here更多细节。它解释说没有API可用于获取无线电信息。

0

你可以试试这个:

public static JSONArray getCellInfo(Context ctx){ 
    TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); 

    JSONArray cellList = new JSONArray(); 

    int phoneTypeInt = tel.getPhoneType(); 
    String phoneType = "unknown"; 
    if (phoneTypeInt == TelephonyManager.PHONE_TYPE_GSM) 
     phoneType = "gsm"; 
    else if (phoneTypeInt == TelephonyManager.PHONE_TYPE_CDMA) 
     phoneType = "cdma"; 

    //from Android M up must use getAllCellInfo 
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { 

     List<NeighboringCellInfo> neighCells = tel.getNeighboringCellInfo(); 
     for (int i = 0; i < neighCells.size(); i++) { 
      try { 
       JSONObject cellObj = new JSONObject(); 
       NeighboringCellInfo thisCell = neighCells.get(i); 
       cellObj.put("cellId", thisCell.getCid()); 
       cellObj.put("lac", thisCell.getLac()); 
       cellObj.put("rssi", thisCell.getRssi()); 
       cellList.put(cellObj); 
      } catch (Exception e) { 
      } 
     } 

    } else { 
     List<CellInfo> infos = tel.getAllCellInfo(); 
     for (int i = 0; i < infos.size(); ++i) { 
      try { 
       JSONObject cellObj = new JSONObject(); 
       CellInfo info = infos.get(i); 
       if (info instanceof CellInfoGsm) { 
        CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength(); 
        CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity(); 
        cellObj.put("cellId", identityGsm.getCid()); 
        cellObj.put("lac", identityGsm.getLac()); 
        cellObj.put("dbm", gsm.getDbm()); 
        cellList.put(cellObj); 
       } else if (info instanceof CellInfoLte) { 
        CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength(); 
        CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity(); 
        cellObj.put("cellId", identityLte.getCi()); 
        cellObj.put("tac", identityLte.getTac()); 
        cellObj.put("dbm", lte.getDbm()); 
        cellList.put(cellObj); 
       } 

      } catch (Exception ex) { 

      } 
     } 
    } 

    return cellList; 
}