Google Maps Android API V2で現在地の住所を表示
private void reverse_geocode(double lat,double lon){ HttpClient httpClient = new DefaultHttpClient(); String uri = "http://maps.googleapis.com/maps/api/geocode/json" + "?latlng=" + lat + "," + lon + "&sensor=true&language=ja"; HttpGet request = new HttpGet(uri.toString()); try { httpResponse = httpClient.execute(request); } catch (Exception e) { Log.d("HttpSampleActivity", "Execute エラー"); } int status = httpResponse.getStatusLine().getStatusCode(); if (HttpStatus.SC_OK == status) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); httpResponse.getEntity().writeTo(outputStream); json_parse(outputStream.toString()); } catch (Exception e) { Log.d("HttpSampleActivity", "エラー"); } } else { Log.d("HttpSampleActivity", "Status" + status); } } private void json_parse(String str) { try { String res = ""; JSONObject rootObject = new JSONObject(str); JSONArray eventArray = rootObject.getJSONArray("results"); for (int i = 0; i < eventArray.length(); i++) { JSONObject jsonObject = eventArray.getJSONObject(i); res = jsonObject.getString("formatted_address"); if (!res.equals("")){ Log.d("Address",res); TextView textview = (TextView) findViewById(R.id.textview1); textview.setText(res); break; } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }