0
這基本上是我的結束url這是給我在瀏覽器中正確的地址組件。但是,當我使用抽射獲取相同的數據我收到錯誤403使用排球獲取地理數據給出錯誤403
final StringBuilder url = new StringBuilder(
"http://maps.googleapis.com/maps/api/geocode/json?sensor=true&latlng=");
url.append(latitude);
url.append(',');
url.append(longitude);
url.append("&language=");
url.append(Locale.getDefault().getLanguage());
// Request a string response from the provided URL.
@SuppressWarnings("rawtypes")
StringRequest stringRequest = new StringRequest(Request.Method.GET, url.toString(),
new Response.Listener() {
@Override
public void onResponse(Object arg0) {
// TODO Auto-generated method stub
System.out.println();
try {
String address = (new JSONObject(arg0.toString())).getJSONArray("results").getJSONObject(0).getString("formatted_address");
location.setText(address);
ProjectUtil.crossfade(layout, progress);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
System.out.println();
}
});
queue.add(stringRequest);