Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do it with <a href="http://code.google.com/apis/maps/documentation/geocoding/" rel="nofollow noreferrer">Google's Geocoding API</a>. What you're actually looking for is reverse-geocoding, but it supports that too. You can have it return XML and then parse it for the postal code (a.k.a zipcode). Should be quite simple actually.</p> <p>To use the API, simply access it by HTTP with the correct latitude and longitude:</p> <p><a href="https://maps.googleapis.com/maps/api/geocode/xml?latlng=37.775,-122.4183333&amp;sensor=true" rel="nofollow noreferrer">https://maps.googleapis.com/maps/api/geocode/xml?latlng=37.775,-122.4183333&amp;sensor=true</a></p> <p>Then parse the XML using XPath, or your favorite XML parser (or just use JSON):</p> <pre><code>XPath xpath = XPathFactory.newInstance().newXPath(); String expression = "//GeocodeResponse/result/address_component[type=\"postal_code\"]/long_name/text()"; InputSource inputSource = new InputSource("https://maps.googleapis.com/maps/api/geocode/xml?latlng=37.775,-122.4183333&amp;sensor=true"); String zipcode = (String) xpath.evaluate(expression, inputSource, XPathConstants.STRING); </code></pre> <p>I haven't actually tested this bit of code (and it obviously needs exception handling), but I trust you'll be able to get it working from here.</p> <p>As for getting the location itself, this previous question sums it up nicely:</p> <p><a href="https://stackoverflow.com/questions/1513485/how-do-i-get-the-current-gps-location-programmatically-in-android">How do I get the current GPS location programmatically in Android?</a></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. 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