Android 基站分CdmaCellLocation和GsmCellLocation,要根据不同的SIM卡转成不同的对象
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int type = tm.getNetworkType();//获取网络类型
//在中国,移动的2G是EGDE,联通的2G为GPRS,电信的2G为CDMA,电信的3G为EVDO
Location loc = null;
ArrayList CellID = new ArrayList();
//中国电信为CTC
//NETWORK_TYPE_EVDO_A是中国电信3G的getNetworkType
//NETWORK_TYPE_CDMA电信2G是CDMA
if (type == TelephonyManager.NETWORK_TYPE_EVDO_A || type == TelephonyManager.NETWORK_TYPE_CDMA || type ==TelephonyManager.NETWORK_TYPE_1xRTT)
{
location = (CdmaCellLocation) tm.getCellLocation();
if(location == null)
throw new Exception("errr");
String operator = tm.getNetworkOperator();
int cellIDs = location.getBaseStationId();
int networkID = location.getNetworkId();
StringBuilder sb = new StringBuilder();
sb.append(location.getSystemId());
int mnc = Integer.parseInt(nsb.toString());
int mcc = Integer.parseInt(operator.substring(0,3));


}
//移动2G卡 + CMCC + 2
//type = NETWORK_TYPE_EDGE
//联通的2G经过测试 China Unicom 1 NETWORK_TYPE_GPRS
else if(type == TelephonyManager.NETWORK_TYPE_EDGE || type == TelephonyManager.NETWORK_TYPE_GPRS)
{
GsmCellLocation location = (GsmCellLocation)tm.getCellLocation();
location = (CdmaCellLocation) tm.getCellLocation();
if(location == null)
throw new Exception("errr");
String operator = tm.getNetworkOperator();
int mcc = Integer.parseInt(operator.substring(0,3));
int mnc = Integer.parseInt(operator.substring(3));
int cid = location.getCid();
int lac = location.getLac();
}

更多相关文章

  1. 【原创】Android 耗电信息统计服务——BatteryStats源码分析(一)
  2. 中国电信已加盟Android阵营
  3. LoRa基站网关-室外型

随机推荐

  1. 从 android sqlite 中获取boolean值
  2. android子线程中刷新界面控件
  3. Android 控件的显示和隐藏
  4. Android WebView中的JavaScript调用andro
  5. 切换选项卡
  6. Android 轮询实现的三种方式
  7. android开源工程
  8. Android系统属性SystemProperties.set/ge
  9. 编译V8静态库 for Android
  10. Android Ble