Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can <em>use</em> of Google Place API in following way</p> <p>create a method that returns a <code>JSONObject</code> with the response of the HTTP Call like following</p> <pre><code>public static JSONObject getLocationInfo(String address) { StringBuilder stringBuilder = new StringBuilder(); try { address = address.replaceAll(" ","%20"); HttpPost httppost = new HttpPost("http://maps.google.com/maps/api/geocode/json?address=" + address + "&amp;sensor=false"); HttpClient client = new DefaultHttpClient(); HttpResponse response; stringBuilder = new StringBuilder(); response = client.execute(httppost); 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) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonObject; } </code></pre> <p>now pass that JSONObject to <strong>getLatLong()</strong> method like following</p> <pre><code>public static GeoPoint getLatLong(JSONObject jsonObject) { Double lon = new Double(0); Double lat = new Double(0); try { lon = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lng"); lat = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lat"); } catch (Exception e) { e.printStackTrace(); } return new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6)); } </code></pre> <p>this is worked and tested...on API level 8...hop this help..</p>
    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. 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.
    3. 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