I am trying to get postal code, but I am unable to get zipcode(postalcode). I can able to get current city but when I try to get the zipcode it's giving me a null pointer exception. Can anyone help me.
final Geocoder gcd = new Geocoder(getApplicationContext(),
Locale.getDefault());
List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1);
if (addresses.size() > 0) Log.d(addresses.get(0).getLocality()); // I can get city name here.
Log.d(addresses.get(0).getPostalCode();// here i am getting nullpoiter exception
addresses.get(1)).getPostalCode()
or try with 2,3,4. After you read this - take a look here - #16516182 – EskilList<Address> addresses = gcd.getFromLocation(latitude, longitude, 1);
. Change the last digit to 3,4 or 5. – Eskilhttp://developer.android.com/reference/android/location/Geocoder.html#getFromLocation(double, double, int)
– Eskil