public static void getCurrentLocation(Context context) {
TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// 返回值MCC + MNC
String operator = mTelephonyManager.getNetworkOperator();
int mcc = Integer.parseInt(operator.substring(0, 3));
int mnc = Integer.parseInt(operator.substring(3));
Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t");
// 中国移动和中国联通获取LAC、CID的方式
GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();
int lac = location.getLac();
int cellId = location.getCid();
// 中国电信获取LAC、CID的方式
CdmaCellLocation location1 = (CdmaCellLocation) mTelephonyManager.getCellLocation();
lac = location1.getNetworkId();
cellId = location1.getBaseStationId();
cellId /= 16;
Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t LAC = " + lac + "\t CID = " + cellId);
// 获取邻区基站信息
List<NeighboringCellInfo> infos = mTelephonyManager.getNeighboringCellInfo();
StringBuffer sb = new StringBuffer("总数 : " + infos.size() + "\n");
for (NeighboringCellInfo info1 : infos) { // 根据邻区总数进行循环
sb.append(" LAC : " + info1.getLac()); // 取出当前邻区的LAC
sb.append(" CID : " + info1.getCid()); // 取出当前邻区的CID
sb.append(" BSSS : " + (-113 + 2 * info1.getRssi()) + "\n"); // 获取邻区基站信号强度
}
Log.i(TAG, " 获取邻区基站信息:" + sb.toString());
}
GSMCellLocationLbs.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:LBS
作者:
评论列表
文章目录