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通过代码来开启和关闭移动网络
  2. Android的联通性---USB的从属模式(一)
  3. 【原创】Android(安卓)耗电信息统计服务——BatteryStats源码分
  4. 【Android】联通性 -- USB从属模式
  5. 【Android】联通性 -- USB从属模式
  6. 中国电信已加盟Android阵营
  7. Google放弃“不做恶”? 意欲垄断Android
  8. android 获取网络类型名称2G 3G 4G wifi
  9. 电信大宽带服务器300M谁家有?

随机推荐

  1. android 弹出带按钮的对话框
  2. Android(安卓)的AsyncTask使用
  3. Android相机开发那些坑
  4. Android(安卓)jetpack Room数据库(一)基本
  5. 一个android访问http资源的便捷工具类―
  6. Android(安卓)JNI入门第一篇――HelloWor
  7. Android(安卓)访问网络连接设置界面
  8. android 使内容铺满全屏
  9. Android(安卓)studio图片ERROR: 9-patch
  10. android沉浸式状态栏实现,android沉浸式状