http://www.google.com/loc/json 返回结果不可用
代码如下
private Location callGear(ArrayList<WifiInfo> wifi, ArrayList<CellIDInfo> cellID) {
if (cellID == null) return null;
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.google.com/loc/json");
JSONObject holder = new JSONObject();
try {
holder.put("version", "1.1.0");
holder.put("host", "maps.google.com");
holder.put("home_mobile_country_code", cellID.get(0).mobileCountryCode);
holder.put("home_mobile_network_code", cellID.get(0).mobileNetworkCode);
holder.put("radio_type", cellID.get(0).radioType);
holder.put("request_address", true);
if ("460".equals(cellID.get(0).mobileCountryCode))
holder.put("address_language", "zh_CN");
else
holder.put("address_language", "en_US");
JSONObject data,current_data;
JSONArray array = new JSONArray();
current_data = new JSONObject();
current_data.put("cell_id", cellID.get(0).cellId);
current_data.put("mobile_country_code", cellID.get(0).mobileCountryCode);
current_data.put("mobile_network_code", cellID.get(0).mobileNetworkCode);
current_data.put("age", 0);
array.put(current_data);
if (cellID.size() > 2) {
for (int i = 1; i < cellID.size(); i++) {
data = new JSONObject();
data.put("cell_id", cellID.get(i).cellId);
data.put("location_area_code", cellID.get(0).locationAreaCode);
data.put("mobile_country_code", cellID.get(0).mobileCountryCode);
data.put("mobile_network_code", cellID.get(0).mobileNetworkCode);
data.put("age", 0);
array.put(data);
}
}
holder.put("cell_towers", array);
if (wifi.get(0).mac != null) {
data = new JSONObject();
data.put("mac_address", wifi.get(0).mac);
data.put("signal_strength", 8);
data.put("age", 0);
array = new JSONArray();
array.put(data);
holder.put("wifi_towers", array);
}
StringEntity se = new StringEntity(holder.toString());
//Log.e("Location send", 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) {
//Log.e("Locaiton reseive", result);
sb.append(result);
result = br.readLine();
}
data = new JSONObject(sb.toString());
data = (JSONObject) data.get("location");
Location loc = new Location(LocationManager.NETWORK_PROVIDER);
loc.setLatitude((Double) data.get("latitude"));
loc.setLongitude((Double) data.get("longitude"));
loc.setAccuracy(Float.parseFloat(data.get("accuracy").toString()));
//loc.setTime(AppUtil.getUTCTime());
return loc;
} catch (JSONException e) {
return null;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
//} catch (ClientProtocolException e) {
// e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>??????-???</title><link href="/v30/css/site.css" rel="stylesheet" type="text/css" /></head><body><div id="shouye"><div class="top"><div class="top_01"></div><div class="top_06"></div><div class="top_03"></div><div class="top_04_1"><ul class="daoh"><li class="daoh_1_b">???</li><li class="daoh_2"><a href="/v30/intro.jsp">????????</a></li><li class="daoh_3"><a href="http://wlan.vnet.cn" target="_blank">???????</a></li><li class="daoh_4"><a href="/v30/userGuid.jsp">??????</a></li><li class="daoh_5"><a href="http://www.fj.ct10000.com" target="_blank">????????</a></li><li class="daoh_6"><a href="/v30/questions.jsp">????????</a></li><li class="daoh_7"><a href="/v30/download.jsp">???????</a></li><li class="daoh_8"><a href="/v30/roaming.jsp" target="_blank" style="text-decoration:underline; ">Global Roaming</a></li></ul></div><div class="top_05"></div></div><div class="wi"><div class="wi_01"></div><div class="wi_05"></div><div class="wi_03"></div><div class="wi_04"></div></div><div class="xia"><iframe width="1006" height="293" scrolling=No frameborder=0 marginheight=0 marginwidth=0 src="/v30/cdmaContainer.jsp" allowtransparency="true"></iframe></div><div class="t_a"><img src="/v30/images/bottom.jpg"></div></div><!--Promotion floating area before:Sat Dec 31 00:00:00 CST 2011--><script type="text/javascript">//clickClose---begin----function hidead(){document.getElementById("floatAd").style.display="none";}//clickClose---end----function floatAD() {var L=T=0var R= document.body.clientWidth-obj.offsetWidthvar B = document.body.clientHeight-obj.offsetHeightobj.style.left = x + document.body.scrollLeftobj.style.top = y + document.body.scrollTopx = x + step*(xin?1:-1)if (x < L) { xin = true; x = L}if (x > R){ xin = false; x = R}y = y + step*(yin?1:-1)if (y < T) { yin = true; y = T }if (y > B) { yin = false; y = B }}</script><table width="330" height="177" border="0" cellpadding="0" cellspacing="0" id="floatAd" style="position:absolute;overflow:hidden; "><tr height="29"><td width="330" height="29" background="/floatAD/images/title.jpg"><div onclick="hidead();" style="float:right;margin-right:5px;cursor:pointer;margin-top:0px;display:inline;"><img src="/floatAD/images/1.jpg" border="0"/></div></td></tr><tr height="148"><a href="http://sh.ct10000.com/v3/workbench/tyt/tytExplain.jsp" target="_blank"><td style="cursor:pointer;background-image:url(/floatAD/images/cardAD.jpg);"></td></a></tr></table><script type="text/javascript">//float---begin---var x = 50,y = 60var xin = true, yin = truevar step = 1var delay = 1var obj=document.getElementById("floatAd")var itl= setInterval("floatAD()", delay)obj.onmouseover=function(){clearInterval(itl)}obj.onmouseout=function(){itl=setInterval("floatAD()", delay)}//float---end---</script> </body></html>
{
"address_language":"zh_CN",
"wifi_towers":[
{"mac_address":"00-1f-33-7b-a4-ef","signal_strength":-81,"ssid":"ChinaNet","age":0},
{"mac_address":"28-93-fe-c5-b3-80","signal_strength":-61,"ssid":"wrv210-new8511f","age":0},
{"mac_address":"4c-e6-76-46-8f-c6","signal_strength":-68,"ssid":"new851-east","age":0},
{"mac_address":"06-1f-33-7b-a4-cf","signal_strength":-76,"ssid":"NETGEAR - 1","age":0},
{"mac_address":"06-1f-33-7b-a4-ef","signal_strength":-88,"ssid":"NETGEAR - 1","age":0},
{"mac_address":"00-1f-33-7b-a5-07","signal_strength":-91,"ssid":"ChinaNet","age":0},
{"mac_address":"06-1f-33-7b-a5-07","signal_strength":-92,"ssid":"NETGEAR - 1","age":0},
{"mac_address":"00-13-46-40-36-ec","signal_strength":-93,"ssid":"new851-2f","age":0}
],
"request_address":true,
"cell_towers":[
{"mobile_country_code":460,"location_area_code":24604,"signal_strength":-111,"cell_id":"19173","mobile_network_code":0,"age":0},
{"mobile_country_code":460,"location_area_code":24604,"signal_strength":-107,"cell_id":"1612463645","mobile_network_code":0,"age":0},
{"mobile_country_code":460,"location_area_code":24604,"signal_strength":-103,"cell_id":"1612448975","mobile_network_code":0,"age":0},
{"mobile_country_code":460,"location_area_code":24604,"signal_strength":-99,"cell_id":"1612463648","mobile_network_code":0,"age":0},
{"mobile_country_code":460,"location_area_code":24604,"signal_strength":-95,"cell_id":"1612448978","mobile_network_code":0,"age":0},
{"mobile_country_code":460,"location_area_code":24604,"signal_strength":-91,"cell_id":"1612466915","mobile_network_code":0,"age":0},
{"mobile_country_code":460,"location_area_code":24604,"signal_strength":-87,"cell_id":"1612450296","mobile_network_code":0,"age":0}
],
"carrier":"HTC",
"host":"maps.google.com",
"version":"1.1.0",
"radio_type":"gsm"
}
{ "version": "1.1.0", "host": "maps.google.com", "home_mobile_country_code": 310, "home_mobile_network_code": 410, "radio_type": "gsm", "carrier": "Vodafone", "request_address": true, "address_language": "en_GB", "location": { "latitude": 51.0, "longitude": -0.1 }, "cell_towers": [ { "cell_id": "42", "location_area_code": 415, "mobile_country_code": 310, "mobile_network_code": 410, "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": "01-23-45-67-89-ab", "signal_strength": 8, "age": 0 }, { "mac_address": "01-23-45-67-89-ac", "signal_strength": 4, "age": 0 } ] }
可返回结果就是不正确:
[code=HTML]
\r\n\r\n\r\n\r\n\r\n\r\n\r\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n<html xmlns="http://www.w3.org/1999/xhtml">\r\n<head>\r\n<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />\r\n<title>??????-???</title>\r\n<link href="/v30/css/site.css" rel="stylesheet" type="text/css" />\r\n</head>\r\n<body>\r\n<div id="shouye">\r\n\t<div class="top">\r\n\t\t<div class="top_01"></div>\r\n\t\t<div class="top_06"></div>\r\n\t\t<div class="top_03"></div>\r\n\t\t<div class="top_04_1">\r\n\t\t\t<ul class="daoh">\r\n\t\t\t\t<li class="daoh_1_b">???</li>\r\n\t\t\t\t<li class="daoh_2"><a href="/v30/intro.jsp">????????</a></li>\r\n\t\t\t\t<li class="daoh_3"><a href="http://wlan.vnet.cn" target="_blank">???????</a></li>\r\n\t\t\t\t<li class="daoh_4"><a href="/v30/userGuid.jsp">??????</a></li>\r\n\t\t\t\t<li class="daoh_5"><a href="http://www.fj.ct10000.com" target="_blank">????????</a></li>\r\n\t\t\t\t<li class="daoh_6"><a href="/v30/questions.jsp">????????</a></li>\r\n\t\t\t\t<li class="daoh_7"><a href="/v30/download.jsp">???????</a></li>\r\n\t\t\t\t<li class="daoh_8"><a href="/v30/roaming.jsp" target="_blank" style="text-decoration:underline; ">Global Roaming</a></li>\r\n\t\t\t</ul>\r\n\t\t</div>\r\n\t\t<div class="top_05"></div>\r\n\t</div>\r\n\t<div class="wi">\r\n\t\t<div class="wi_01"></div>\r\n\t\t<div class="wi_05"></div>\r\n\t\t<div class="wi_03"></div>\r\n\t\t<div class="wi_04"></div>\r\n\t</div>\r\n\t<div class="xia">\r\n\t\t<iframe width="1006" height="293" scrolling=No frameborder=0 marginheight=0 marginwidth=0 src="/v30/cdmaContainer.jsp" allowtransparency="true"></iframe>\r\n\t</div>\r\n\t<div class="t_a"><img src="/v30/images/bottom.jpg"></div>\r\n</div>\r\n\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\t<!--Promotion floating area before:Sat Dec 31 00:00:00 CST 2011-->\r\n\t<script type="text/javascript">\r\n\t\t//clickClose---begin----\r\n\t\tfunction hidead(){\r\n\t\t\tdocument.getElementById("floatAd").style.display="none";\r\n\t\t}\r\n\t\t//clickClose---end----\r\n\t\tfunction floatAD() {\r\n\t\t\tvar L=T=0\r\n\t\t\tvar R= document.body.clientWidth-obj.offsetWidth\r\n\t\t\tvar B = document.body.clientHeight-obj.offsetHeight\r\n\t\t\tobj.style.left = x + document.body.scrollLeft\r\n\t\t\tobj.style.top = y + document.body.scrollTop\r\n\t\t\tx = x + step*(xin?1:-1)\r\n\t\t\tif (x < L) { xin = true; x = L}\r\n\t\t\tif (x > R){ xin = false; x = R}\r\n\t\t\ty = y + step*(yin?1:-1)\r\n\t\t\tif (y < T) { yin = true; y = T }\r\n\t\t\tif (y > B) { yin = false; y = B }\r\n\t\t}\r\n\t</script>\r\n\r\n\t<table width="330" height="177" border="0" cellpadding="0" cellspacing="0" id="floatAd" style="position:absolute;overflow:hidden; ">\r\n\t\t<tr height="29">\r\n\t\t\t<td width="330" height="29" background="/floatAD/images/title.jpg">\r\n\t\t\t\t<div onclick="hidead();" style="float:right;margin-right:5px;cursor:pointer;margin-top:0px;display:inline;">\r\n\t\t\t\t\t<img src="/floatAD/images/1.jpg" border="0"/>\r\n\t\t\t\t</div>\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr height="148">\r\n\t\t\t<a href="http://sh.ct10000.com/v3/workbench/tyt/tytExplain.jsp" target="_blank"><td style="cursor:pointer;background-image:url(/floatAD/images/cardAD.jpg);"></td></a>\r\n\t\t</tr>\r\n\t</table>\r\n\t<script type="text/javascript">\r\n\t//float---begin---\r\n\t\tvar x = 50,y = 60\r\n\t\tvar xin = true, yin = true\r\n\t\tvar step = 1\r\n\t\tvar delay = 1\r\n\t\tvar obj=document.getElementById("floatAd")\r\n\t\tvar itl= setInterval("floatAD()", delay)\r\n\t\tobj.onmouseover=function(){clearInterval(itl)}\r\n\t\tobj.onmouseout=function(){itl=setInterval("floatAD()", delay)}\r\n\t//float---end---\r\n\t</script>\r\n\r\n \r\n\r\n \r\n\r\n\r\n\r\n</body>\r\n</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>??????-???</title>
<link href="/v30/css/site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="shouye">
<div class="top">
<div class="top_01"></div>
<div class="top_06"></div>
<div class="top_03"></div>
<div class="top_04_1">
<ul class="daoh">
<li class="daoh_1_b">???</li>
<li class="daoh_2"><a href="/v30/intro.jsp">????????</a></li>
<li class="daoh_3"><a href="http://wlan.vnet.cn" target="_blank">???????</a></li>
<li class="daoh_4"><a href="/v30/userGuid.jsp">??????</a></li>
<li class="daoh_5"><a href="http://www.fj.ct10000.com" target="_blank">????????</a></li>
<li class="daoh_6"><a href="/v30/questions.jsp">????????</a></li>
<li class="daoh_7"><a href="/v30/download.jsp">???????</a></li>
<li class="daoh_8"><a href="/v30/roaming.jsp" target="_blank" style="text-decoration:underline; ">Global Roaming</a></li>
</ul>
</div>
<div class="top_05"></div>
</div>
<div class="wi">
<div class="wi_01"></div>
<div class="wi_05"></div>
<div class="wi_03"></div>
<div class="wi_04"></div>
</div>
<div class="xia">
<iframe width="1006" height="293" scrolling=No frameborder=0 marginheight=0 marginwidth=0 src="/v30/cdmaContainer.jsp" allowtransparency="true"></iframe>
</div>
<div class="t_a"><img src="/v30/images/bottom.jpg"></div>
</div>
<!--Promotion floating area before:Sat Dec 31 00:00:00 CST 2011-->
<script type="text/javascript">
//clickClose---begin----
function hidead(){
document.getElementById("floatAd").style.display="none";
}
//clickClose---end----
function floatAD() {
var L=T=0
var R= document.body.clientWidth-obj.offsetWidth
var B = document.body.clientHeight-obj.offsetHeight
obj.style.left = x + document.body.scrollLeft
obj.style.top = y + document.body.scrollTop
x = x + step*(xin?1:-1)
if (x < L) { xin = true; x = L}
if (x > R){ xin = false; x = R}
y = y + step*(yin?1:-1)
if (y < T) { yin = true; y = T }
if (y > B) { yin = false; y = B }
}
</script>
<table width="330" height="177" border="0" cellpadding="0" cellspacing="0" id="floatAd" style="position:absolute;overflow:hidden; ">
<tr height="29">
<td width="330" height="29" background="/floatAD/images/title.jpg">
<div onclick="hidead();" style="float:right;margin-right:5px;cursor:pointer;margin-top:0px;display:inline;">
<img src="/floatAD/images/1.jpg" border="0"/>
</div>
</td>
</tr>
<tr height="148">
<a href="http://sh.ct10000.com/v3/workbench/tyt/tytExplain.jsp" target="_blank"><td style="cursor:pointer;background-image:url(/floatAD/images/cardAD.jpg);"></td></a>
</tr>
</table>
<script type="text/javascript">
//float---begin---
var x = 50,y = 60
var xin = true, yin = true
var step = 1
var delay = 1
var obj=document.getElementById("floatAd")
var itl= setInterval("floatAD()", delay)
obj.onmouseover=function(){clearInterval(itl)}
obj.onmouseout=function(){itl=setInterval("floatAD()", delay)}
//float---end---
</script>
</body>
</html>