`
luckliu521
  • 浏览: 252912 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Android 获取基站信息

阅读更多
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();
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics