Geocoder not avialable, solusinya

public static List<Address> getStringFromLocation(double lat, double lng)
        throws ClientProtocolException, IOException, JSONException {
String address = String.format(Locale.ENGLISH, "http://maps.googleapis.com/maps/api/geocode/json?latlng=%1$f,%2$f&sensor=false", lat, lng);
HttpGet httpGet = new HttpGet(address);
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
HttpResponse response;
StringBuilder stringBuilder = new StringBuilder();
List<Address> retList = null
response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream stream = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
String line;
while ((line = reader.readLine()) != null)
stringBuilder.append(line);
    JSONObject jsonObject = new JSONObject();
jsonObject = new JSONObject(stringBuilder.toString());
retList = new ArrayList<Address>();
if ("OK".equalsIgnoreCase(jsonObject.getString("status"))) {
   JSONArray results = jsonObject.getJSONArray("results");
for (int i = 0; i < results.length(); i++) {
    JSONObject result = results.getJSONObject(i);
    String indiStr = result.getString("formatted_address");
   Address addr = new Address(Locale.getDefault());
    addr.setAddressLine(0, indiStr);
    retList.add(addr);
}  
}
return retList;
}

Ref: http://blog.kozaxinan.com/2013/09/geocoder-is-not-working-instead-use.html

Popular posts from this blog

Android C2DM (Cloud to Device Message) adalah

Menambahkan data pada TreeView delphi dari database mysql

Menampilkan tanggal fastreport delphi