在Android中 怎么获取基站信息。高分酬谢
解决方案 »
- android开发中点击Button按钮,怎么就跳转到menu上了呢?
- 关于PuzzleView
- android开发调用Intent出错
- R cannot be resolved to a variable
- 为什么我的这段代码只能播放音频不能播放视频,路径是我测试用的,大家可以改改试试。谢谢大家了
- 做嵌入式好还是做android开发好
- 为什么在Eclipse配置完Android后没有Android Project?
- android中应用对自身手机端口通信的问题
- android 怎么实现触摸屏校正
- Tabhost,点击tab时修改tabhost里面的布局
- 关于viewpager的问题
- RadioGroup问题!!(求助)
得到GsmCellLocation 这个对象有你要的
public PhoneStateListener celllistener = new PhoneStateListener() {
@Override
public void onCellLocationChanged(CellLocation location) {
super.onCellLocationChanged(location);
// 判断 location的类型 是GsmCellLocation 还是 CdmaCellLocation
// 最后 根据你的业务 需求 实现你的代码 }
};
CELL/NODEB/RNC/CN你要的是哪个?
cellLocation = (GsmCellLocation)telephone.getCellLocation();
cellLocation在android2.2以上的版本中运行为null怎么解决啊
十分感谢!
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就是基站里包含的信息了,你再解析一下就可以了