有谁知道如何检索Android上的GSM和CDMA手机信号塔列表。检索手机信息塔信息
我一直在尝试使用谷歌地图API地点: https://developers.google.com/maps/documentation/business/geolocation/
而且我想要得到的蜂窝塔与这些领域的信息:
- CELLID:小区的唯一标识符。在GSM上,这是Cell ID(CID); CDMA网络使用基站ID(BID)。
- locationAreaCode:GSM网络的位置区域码(LAC); CDMA网络使用网络ID(NID)。
- mobileCountryCode:手机塔的移动国家代码(MCC)。
- mobileNetworkCode:手机塔的移动网络代码。这是GSM的MNC,或CDMA的系统ID(SID)。
- 年龄:自该单元格为主之后的毫秒数。如果age为0,则cellId表示当前的度量。
- signalStrength:无线信号强度,单位为dBm。
- timingAdvance:时间提前值。
此代码不会特别让基站的信息。
TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// Type of the network
int phoneTypeInt = tel.getPhoneType();
String phoneType = null;
phoneType = phoneTypeInt == TelephonyManager.PHONE_TYPE_GSM ? "gsm" : phoneType;
phoneType = phoneTypeInt == TelephonyManager.PHONE_TYPE_CDMA ? "cdma" : phoneType;
try {
if (phoneType != null) {
params.put("radioType", phoneType);
}
} catch (Exception e) {}
/*
* The below code doesn't work I think.
*/
JSONArray cellList = new JSONArray();
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());
cellList.put(cellObj);
} catch (Exception e) {}
}
if (cellList.length() > 0) {
try {
params.put("cellTowers", cellList);
} catch (JSONException e) {}
}
我设置权限,这样的:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
请帮帮我,谢谢。
“我的代码工作,除了获得基站的信息”是你的症状无用的描述。请花时间详细解释什么是和不在工作。 – CommonsWare
对不起,英语不是我的主要语言。 当我在Android上运行代码(载体是sprint)时,“tel.getNeighboringCellInfo();”返回值始终为空。 – wf9a5m75
即使我尝试GSM网络的其他Android上的代码,我也得到了相同的结果。 所以我的问题是如何获取手机信息塔信息。 – wf9a5m75