Possible Duplicate:
ZipCode from location
I need to find zip code for current location. Is this possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do it with Google’s Geocoding API. 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.
To use the API, simply access it by HTTP with the correct latitude and longitude:
https://maps.googleapis.com/maps/api/geocode/xml?latlng=37.775,-122.4183333&sensor=true
Then parse the XML using XPath, or your favorite XML parser (or just use JSON):
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.
As for getting the location itself, this previous question sums it up nicely:
How do I get the current GPS location programmatically in Android?