public CellInfo getNewCellInfo() {
try {
TelephonyManager tm = (TelephonyManager) CellService.get().getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();
/* Why I use this Bitmask:
* https://stackoverflow.com/questions/9808396/android-cellid-not-available-on-all-carriers#12969638
*/
int cellID = location.getCid();// & 0xffff;
int lac = location.getLac();
String networkOperator = tm.getNetworkOperator();
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
int mnc = Integer.parseInt(networkOperator.substring(3));
return new CellInfo(cellID, lac, mnc, mcc, tm.getNetworkType());
} catch (Exception e) {
return new FakeCellInfo();
}
}
CellInfoObserver.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:cellservice
作者:
评论列表
文章目录