获取范围内所有蜂窝塔的CID,LAC和信号强度 [英] Getting CID, LAC and signal strength of all cell towers in range

查看:263
本文介绍了获取范围内所有蜂窝塔的CID,LAC和信号强度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在使用网络中的单元对Android进行三边测量.它比我想像的还要准确.但不如我希望的那样准确.因此,我想涉及的塔比getNeighboringCellInfo获得的塔还要多.我想获取范围内每个塔的小区ID和信号强度.每个网络运营商.有没有一种方法可以"ping"这些塔,以便它们使用cellID,Lac和信号强度进行回答?以某种方式这必须是可能的. 我可以并行扫描2G和3G(和4G)吗?还是可以通过编程在它们之间切换? 有什么建议?希望我足够清楚...

Currently I am trilaterating my Android with the cells in my network. It is even more accurate than I thought it would be. But not as accurate as I want it to be. So I want to involve more towers than I get from getNeighboringCellInfo. I want to get the Cell ID and signal strength of every tower in range. Of every network operater. Is there a way to "ping" the towers, so they answer with cellID, Lac and signalstrength? Somehow this has to be possible. And can I scan the 2G and 3G (and 4G) parallel? Or can I switch between them programmatically? Any suggestions? Hope I'm clear enough...

推荐答案

似乎您正在寻找TelephonyManagergetNeighboringCellInfo().

这里有个例子,很简单明了:

Here's a example, which is easy and straight forward:

/* first you wanna get a telephony manager by asking the system service */
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

/* then you can query for all the neighborhood cells */
List<NeighboringCellInfo> neighbors = tm.getNeighboringCellInfo();

/* here's something you can get from NeighboringCellInfo */
for (NeighboringCellInfo n : neighbors) {
    Log.v("CellInfo", "" + n.getCid());
    Log.v("CellInfo", "" + n.getLac());
    Log.v("CellInfo", "" + n.getPsc());
    Log.v("CellInfo", "" + n.getRssi());
}

根据清单文件中要使用的API,确保包含所有必需的权限,例如ACCESS_COARSE_LOCATIONREAD_PHONE_STATE,否则它将崩溃.

Make sure you include all the permissions required, such as ACCESS_COARSE_LOCATION or READ_PHONE_STATE, depending on what API you'll be using, in your manifest file, or it'll simply crash.

哦,顺便说一句,这仅适用于2G. 3G或更高版本不支持这种操作.

Oh btw this only works for 2G. 3G or above doesn't support this kind of operation.

这篇关于获取范围内所有蜂窝塔的CID,LAC和信号强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆