Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To change back human readable format, you can also use Geocoder but that is not working sometimes because google play service problem. I used this json geocodeing as second option for in case.</p> <p>Please refer <a href="https://developers.google.com/maps/documentation/geocoding/">Google Geocoding API</a></p> <p>Workflow is pass your latitude and longitude and get current location. Request url gonna be like this.</p> <pre><code>String reqURL = "http://maps.googleapis.com/maps/api/geocode/json?latlng="+ lat+","+lng +"&amp;sensor=true"; </code></pre> <p>Hopefully, this answer will help you.</p> <pre><code>public static JSONObject getLocationInfo(double lat, double lng) { HttpGet httpGet = new HttpGet("http://maps.googleapis.com/maps/api/geocode/json?latlng="+ lat+","+lng +"&amp;sensor=true"); HttpClient client = new DefaultHttpClient(); HttpResponse response; StringBuilder stringBuilder = new StringBuilder(); try { response = client.execute(httpGet); HttpEntity entity = response.getEntity(); InputStream stream = entity.getContent(); int b; while ((b = stream.read()) != -1) { stringBuilder.append((char) b); } } catch (ClientProtocolException e) { } catch (IOException e) { } JSONObject jsonObject = new JSONObject(); try { jsonObject = new JSONObject(stringBuilder.toString()); } catch (JSONException e) { e.printStackTrace(); } return jsonObject; } public static String getCurrentLocationViaJSON(double lat, double lng) { JSONObject jsonObj = getLocationInfo(lat, lng); Log.i("JSON string =&gt;", jsonObj.toString()); String currentLocation = "testing"; String street_address = null; String postal_code = null; try { String status = jsonObj.getString("status").toString(); Log.i("status", status); if(status.equalsIgnoreCase("OK")){ JSONArray results = jsonObj.getJSONArray("results"); int i = 0; Log.i("i", i+ "," + results.length() ); //TODO delete this do{ JSONObject r = results.getJSONObject(i); JSONArray typesArray = r.getJSONArray("types"); String types = typesArray.getString(0); if(types.equalsIgnoreCase("street_address")){ street_address = r.getString("formatted_address").split(",")[0]; Log.i("street_address", street_address); }else if(types.equalsIgnoreCase("postal_code")){ postal_code = r.getString("formatted_address"); Log.i("postal_code", postal_code); } if(street_address!=null &amp;&amp; postal_code!=null){ currentLocation = street_address + "," + postal_code; Log.i("Current Location =&gt;", currentLocation); //Delete this i = results.length(); } i++; }while(i&lt;results.length()); Log.i("JSON Geo Locatoin =&gt;", currentLocation); return currentLocation; } } catch (JSONException e) { Log.e("testing","Failed to load JSON"); e.printStackTrace(); } return null; } </code></pre> <p>As my experience, <strong>only device generated latitude and longitude</strong> will work. Then call </p> <pre><code>String currentLocation = getCurrentLocationViaJSON(lat, lng); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload