值得一提的是C网获取基站再定位那偏差不是一般的大,是恨大,将近1千米了,大概是C网基站较少的缘故吧
最后通过经纬度获取地理位置信息,代码如下:
- public static String getAddress(Location itude) throws Exception {
- String resultString = "";
- /** 这里采用get方法,直接将参数加到URL上 */
- String urlString = String.format("http://maps.google.cn/maps/geo?key=abcdefg&q=%s,%s", itude.getLatitude(), itude.getLongitude());
- Log.i("URL", urlString);
- /** 新建HttpClient */
- HttpClient client = new DefaultHttpClient();
- /** 采用GET方法 */
- HttpGet get = new HttpGet(urlString);
- try {
- /** 发起GET请求并获得返回数据 */
- HttpResponse response = client.execute(get);
- HttpEntity entity = response.getEntity();
- BufferedReader buffReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringBuffer strBuff = new StringBuffer();
- String result = null;
- while ((result = buffReader.readLine()) != null) {
- strBuff.append(result);
- }
- resultString = strBuff.toString();
- Log.e("resultAdress--->", resultString);
- /** 解析JSON数据,获得物理地址 */
- if (resultString != null && resultString.length() > 0) {
- JSONObject jsonobject = new JSONObject(resultString);
- JSONArray jsonArray = new JSONArray(jsonobject.get("Placemark").toString());
- resultString = "";
- for (int i = 0; i < jsonArray.length(); i++) {
- resultString = jsonArray.getJSONObject(i).getString("address");
- }
- }
- } catch (Exception e) {
- throw new Exception("获取物理位置出现错误:" + e.getMessage());
- } finally {
- get.abort();
- client = null;
- }
- return resultString;
- }
在获取地理位置的这个location事实上应该传入纠偏后的location,本文暂不做此处理,所以得到的地理信息位置是偶偏差的,大家注意
最后附上截图:

工程下载链接:
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2012年资料/6月/15日/Android GSM+CDMA基站定位/
