手机基站定位源码
2013-04-25 14:25
253 查看
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; /** * Java利用CellID LAC调用Google接口获取经纬度例子 */ public class GoogleJson { public static void main(String args[]) { GoogleJson test = new GoogleJson(); URL url = null; HttpURLConnection conn = null; try { url = new URL("http://www.google.com/loc/json"); conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); String json = test.getJson(); System.out.println(json); conn.getOutputStream().write(json.getBytes()); conn.getOutputStream().flush(); conn.getOutputStream().close(); int code = conn.getResponseCode(); System.out.println("code " + code); BufferedReader in = new BufferedReader(new InputStreamReader( conn.getInputStream())); String inputLine; inputLine = in.readLine(); System.out.println(inputLine); in.close(); // 解析结果 // JSONObject result = new JSONObject(inputLine); // JSONObject location = result.getJSONObject("location"); // JSONObject address = location.getJSONObject("address"); // System.out.println("city = " + address.getString("city")); // System.out.println("region = " + address.getString("region")); } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) conn.disconnect(); } } /** * Google的官方例子 */ private String getJson() { String json = "{ " + "\"version\": \"1.1.0\", " + "\"host\": \"maps.google.com\", " // + // "\"access_token\": \"2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe\", " + "\"home_mobile_country_code\": 460, " + "\"home_mobile_network_code\": 00, " + "\"radio_type\": \"gsm\", " + "\"carrier\": \"Vodafone\", " + "\"request_address\": true, " + "\"address_language\": \"zh_CN\", " // + "\"location\": { " // + "\"latitude\": 51.0, " + "\"longitude\": -0.1 " + "}, " + "\"cell_towers\": [ " + "{ " + "\"cell_id\": 4912, " + "\"location_area_code\": 20516, " + "\"mobile_country_code\": 460, " + "\"mobile_network_code\": 00, " + "\"age\": 0, " + "\"signal_strength\": -60, " + "\"timing_advance\": 5555 " + "}" // +", " + "{ " + "\"cell_id\": 88, " // + "\"location_area_code\": 415, " // + "\"mobile_country_code\": 310, " // + "\"mobile_network_code\": 580, " + "\"age\": 0, " // + "\"signal_strength\": -70, " + "\"timing_advance\": 7777 " // + "}" + "]" // +", " + "\"wifi_towers\": [ " + "{ " // + "\"mac_address\": \"00:18:39:f4:29:01\", " // + "\"signal_strength\": 8, " + "\"age\": 0 " + " }" // // ", " + "{ " // // + " \"mac_address\": \"01-23-45-67-89-ac\", " // // + " \"signal_strength\": 4, " + " \"age\": 0 " + "}" // + "] " + "}"; return json; } }
相关文章推荐
- 手机基站定位(安卓手机定位源码)
- Android基站定位——通过手机信号获取基站信息(一)
- C# 使用Google API进行手机基站定位资料整理
- Android获取手机基站信息并进行基站定位(基站定位原理)
- Android基站定位——通过手机信号获取基站信息(一)
- android开发通过基站手机网络实现定位功能(Google实现)
- 谷歌手机地图支持三角基站定位
- C# 使用Google API进行手机基站定位资料整理
- 手机自带的显示基站命令(android手机定位,iphone基站定位)
- 分享Android CellLocation源码,基于Rexsee对象的基站定位功能
- 利用基站定位手机
- 基站定位数据库(简单的手机基站定位数据获取)
- 【转】C# 使用Google API进行手机基站定位资料整理
- 分享Android CellLocation源码,基于Rexsee对象的基站定位功能
- Android获取手机基站信息并进行基站定位(基站定位原理)
- 浅谈手机基站定位
- 分享Android CellLocation源码,基于Rexsee对象的基站定位功能
- 浅析手机定位---GPS、基站、AGPS、WIFI
- Android基站定位——通过手机信号获取基站信息
- Android基站定位——通过手机信号获取基站信息(一)