Android获取基站信息,高手请进

tt6550619 2011-02-16 08:39:57
在Android中 怎么获取基站信息。高分酬谢
...全文
6310 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoba555 2012-11-21
  • 打赏
  • 举报
回复
貌似没有作用的提问
zpf_cn 2011-11-16
  • 打赏
  • 举报
回复
可以看看rexsee的源码。rexsee现在开源了。
dongyongyang 2011-07-23
  • 打赏
  • 举报
回复
TelephonyManager tm;
tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation gcl = (GsmCellLocation) tm.getCellLocation();
int cid = gcl.getCid();
int lac = gcl.getLac();
int mcc = Integer.valueOf(tm.getNetworkOperator().substring(0,3));
int mnc = Integer.valueOf(tm.getNetworkOperator().substring(3,5));
try {
// 组装JSON查询字符串
JSONObject holder = new JSONObject();
holder.put("version", "1.1.0");
holder.put("host", "maps.google.com");
// holder.put("address_language", "zh_CN");
holder.put("request_address", true);
JSONArray array = new JSONArray();
JSONObject data = new JSONObject();
data.put("cell_id", cid); // 25070
data.put("location_area_code", lac);// 4474
data.put("mobile_country_code", mcc);// 460
data.put("mobile_network_code", mnc);// 0
array.put(data);
holder.put("cell_towers", array);
// 创建连接,发送请求并接受回应
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.google.com/loc/json");
StringEntity se = new StringEntity(holder.toString());
post.setEntity(se);
HttpResponse resp = client.execute(post);
HttpEntity entity = resp.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
StringBuffer sb = new StringBuffer();
String result = br.readLine();
while (result != null) {
sb.append(result);
result = br.readLine();
}
String message=sb.toString();
这个message就是基站里包含的信息了,你再解析一下就可以了
阿军 2011-06-26
  • 打赏
  • 举报
回复
请大家能给我一个Demo例子,获取基站的编号和信号强度以及时间的偏移度
十分感谢!
justin000 2011-06-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 drsmart 的回复:]

android获取cellid比较简单,你可以试试获取邻接基站id,这样三角定位更准确些
[/Quote]


你好 请问怎么一次获得多个基站的信息阿
tt6550619 2011-02-20
  • 打赏
  • 举报
回复
telephone = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
cellLocation = (GsmCellLocation)telephone.getCellLocation();
cellLocation在android2.2以上的版本中运行为null怎么解决啊
tt6550619 2011-02-20
  • 打赏
  • 举报
回复
我在android2.2以上的版本获取GsmCellLocation的时候是null值啊
芸芸芸芸 2011-02-20
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 drsmart 的回复:]
settings-location & security 中第一项你勾选了吗
[/Quote]

是干什么的啊???
raoyongchao 2011-02-20
  • 打赏
  • 举报
回复
基站定位不是太准确,有时偏差很大,只能获取大概位置
tt6550619 2011-02-20
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 drsmart 的回复:]
settings-location & security 中第一项你勾选了吗
[/Quote]有什么作用?
DrSmart 2011-02-20
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 woaianzhuo 的回复:]
获取基站信息后可以做什么用呢?
[/Quote]

定位啊
woaianzhuo 2011-02-20
  • 打赏
  • 举报
回复
获取基站信息后可以做什么用呢?
DrSmart 2011-02-20
  • 打赏
  • 举报
回复
settings-location & security 中第一项你勾选了吗
tt6550619 2011-02-20
  • 打赏
  • 举报
回复
在哪里设置啊?我android2.2一下的版本都可以啊?
DrSmart 2011-02-20
  • 打赏
  • 举报
回复
你系统的设置中开启了允许network定位没
CyberLogix 2011-02-16
  • 打赏
  • 举报
回复
调用getCellLocation函数
jungwen 2011-02-16
  • 打赏
  • 举报
回复
基站是什么?
CELL/NODEB/RNC/CN你要的是哪个?
儿大不由爷 2011-02-16
  • 打赏
  • 举报
回复
TelephonyManager.getCellLocation();
得到GsmCellLocation 这个对象有你要的
sky123123 2011-02-16
  • 打赏
  • 举报
回复


1、首先 获取服务 telephonyManager =(TelephonyManager) getSystemService(TELEPHONY_SERVICE);

2、注册监听器 telephonyManager.listen(celllistener, PhoneStateListener.LISTEN_CELL_LOCATION); // 基站位置的变化

3、编写监听代码
public PhoneStateListener celllistener = new PhoneStateListener() {
@Override
public void onCellLocationChanged(CellLocation location) {
super.onCellLocationChanged(location);
// 判断 location的类型 是GsmCellLocation 还是 CdmaCellLocation
// 最后 根据你的业务 需求 实现你的代码

}
};

DUDU 2011-02-16
  • 打赏
  • 举报
回复
如果获取了基站信息是不是就可以定位了
通过基站信息来知道该用户的大概位置
加载更多回复(1)

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧