Possible Duplicate:
ZipCode from location
I need to find zip code for current location. Is this possible?
Possible Duplicate:
ZipCode from location
I need to find zip code for current location. Is this possible?
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):
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&sensor=true");
String zipcode = (String) xpath.evaluate(expression, inputSource, XPathConstants.STRING);
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?
There is no "easy way" to get the actual Zip Code of the user. You could use the reverse geocoder function to do this but it doesn't always return the Zip Code, nor is it always accurate. Either way, you'll have to have location services and internet access active in order to do it.
Please check this link.