private static CdmaCellLocation location = null; private static TelephonyManager tm; private static GetBaseLocation get; get = new GetBaseLocation(); tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); getData(); private static void getData() { // mLocationManager.getLocation(activity, 1); int type = tm.getNetworkType(); // 在中国,移动的2G是EGDE,联通的2G为GPRS,电信的2G为CDMA,电信的3G为EVDO // String OperatorName = tm.getNetworkOperatorName(); Location loc = null; ArrayList<CellIDInfo> CellID = new ArrayList<CellIDInfo>(); // 中国电信为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) { try { location = (CdmaCellLocation) tm.getCellLocation(); if (location == null) { return; } int cellIDs = location.getBaseStationId(); int networkID = location.getNetworkId(); StringBuilder nsb = new StringBuilder(); nsb.append(location.getSystemId()); CellIDInfo info = new CellIDInfo(); info.cellId = cellIDs; info.locationAreaCode = networkID; // ok info.mobileNetworkCode = nsb.toString(); info.mobileCountryCode = tm.getNetworkOperator() .substring(0, 3); info.radioType = "cdma"; CellID.add(info); } catch (Exception e) { Log.e("network get the latitude and longitude ocurr Exception error", e.toString()); } } // 移动2G卡 + CMCC + 2 // type = NETWORK_TYPE_EDGE else if (type == TelephonyManager.NETWORK_TYPE_EDGE) { try { GsmCellLocation location = (GsmCellLocation) tm .getCellLocation(); if (location == null) { return; } int cellIDs = location.getCid(); int lac = location.getLac(); CellIDInfo info = new CellIDInfo(); info.cellId = cellIDs; info.locationAreaCode = lac; info.mobileNetworkCode = tm.getNetworkOperator() .substring(3, 5); info.mobileCountryCode = tm.getNetworkOperator() .substring(0, 3); info.radioType = "gsm"; CellID.add(info); } catch (Exception e) { Log.e("network get the latitude and longitude ocurr Exception error", e.toString()); } } // 联通的2G经过测试 China Unicom 1 NETWORK_TYPE_GPRS else if (type == TelephonyManager.NETWORK_TYPE_GPRS) { try { GsmCellLocation location = (GsmCellLocation) tm .getCellLocation(); if (location == null) { return; } int cellIDs = location.getCid(); int lac = location.getLac(); CellIDInfo info = new CellIDInfo(); info.cellId = cellIDs; info.locationAreaCode = lac; // 经过测试,获取联通数据以下两行必须去掉,否则会出现错误,错误类型为JSON Parsing Error // info.mobileNetworkCode = // tm.getNetworkOperator().substring(0, 3); // info.mobileCountryCode = // tm.getNetworkOperator().substring(3); info.radioType = "gsm"; CellID.add(info); } catch (Exception e) { Log.e("network get the latitude and longitude ocurr Exception error", e.toString()); } } else { Commons.LNG = "" + 0; Commons.LAT = "" + 0; } try { loc = get.callGear(CellID); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e("Exception", e.getStackTrace().toString()); System.out.println(e.getStackTrace().toString()); } if (loc != null) { try { Commons.LNG = "" + loc.getLongitude(); Commons.LAT = "" + loc.getLatitude(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Commons.LNG = "" + 0; Commons.LAT = "" + 0; } }
相关推荐
android定位之基站定位,获取不到GPS信号定位时解决定位
android基站定位
这是android实现基站定位的实现步骤及源代码。
Android 基站定位例子
android平台上实现3G基站定位功能,完整源码,多次测试。
android 基站定位程序 目前仅支持联通、移动通信商
Android studio 请使用真机调试,测试地点,最好在室外,基站定位好像不会实时定位,GPS可以2秒刷新一次,前提是可以接收到GPS信号
NULL 博文链接:https://yebingzi.iteye.com/blog/1779276
本DEMO 是基于百度地图定位sdk 写的 基站定位 demo 可以返回 当前位置的具体地址 和 经纬度
源码 博文链接:https://104zz.iteye.com/blog/1680811
Android 基站定位源码.zip
androidGPS及WIFI基站定位坐标源码.zip
android google 定位程序 wifi基站GPS定位 等综合定位代码,
android GPS和基站定位程序及源码.rar 实现基站定位,以及WIFI定位,以及GPS定位,参考使用。
Android的基站、WIFI、GPS定位三点定位结合
Android应用源码之androidGPS及WIFI基站定位坐标源码_androidGPS
android GPS和基站定位程序及源码.rar.rar android GPS和基站定位程序及源码.rar.rar android GPS和基站定位程序及源码.rar.rar
android系统基站定位的源代码,代码实现比较简单易懂,有注释!