我已经多次通过解析包含中文地址信息的Google json来获取地址。但是当我在手机中显示地址时,它全部是英文的。如何获得Google地理编码API的回复,使用默认语言(fx.:Chinese)以外的语言?
我从下面的网址获取json。 http://maps.googleapis.com/maps/api/geocode/json?address=wuhan&sensor=false
编辑: 一个答案的帮助下,我用工作液瓦纳份额:
StringBuffer sb=new StringBuffer();
sb.append("http://maps.googleapis.com/maps/api/geocode/json?latlng=").append(latStr).append(',').append(lonStr).append("&sensor=false&Accept-Language:zh-CN");
String url=sb.toString();
HttpClient httpClient=new DefaultHttpClient();
String responseData="";
try {
HttpResponse response=httpClient.execute(new HttpGet(url));
response.addHeader("Accept-Language", "zh-CN");
HttpEntity entity=response.getEntity();
BufferedReader bf=new BufferedReader(new InputStreamReader((entity.getContent()),"UTF-8"));
String line="";
while((line=bf.readLine())!=null){
responseData=responseData+line;
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
哪里是问题吗?哪里是你如何调用它的最小样本(甚至没有android代码,但至少你用哪个参数调用了哪个api) – Selvin 2012-01-11 15:47:05
http://maps.googleapis.com/maps/api/geocode/json?address=wuhan&sensor=false – lanyimo 2012-01-11 15:48:31
这json是我解析。 – lanyimo 2012-01-11 15:49:32