在Android中 怎么获取基站信息。高分酬谢

解决方案 »

  1.   

    TelephonyManager.getCellLocation();
    得到GsmCellLocation 这个对象有你要的
      

  2.   

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

  3.   

    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
             // 最后 根据你的业务 需求 实现你的代码      }
      };
      

  4.   

    基站是什么?
    CELL/NODEB/RNC/CN你要的是哪个?
      

  5.   

    我在android2.2以上的版本获取GsmCellLocation的时候是null值啊
      

  6.   

    telephone = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    cellLocation = (GsmCellLocation)telephone.getCellLocation();
    cellLocation在android2.2以上的版本中运行为null怎么解决啊
      

  7.   

    你系统的设置中开启了允许network定位没
      

  8.   

    在哪里设置啊?我android2.2一下的版本都可以啊?
      

  9.   

    settings-location & security 中第一项你勾选了吗
      

  10.   

    请大家能给我一个Demo例子,获取基站的编号和信号强度以及时间的偏移度
    十分感谢!
      

  11.   

    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就是基站里包含的信息了,你再解析一下就可以了
      

  12.   

    可以看看rexsee的源码。rexsee现在开源了。