我正在尝试获取邮政编码,但无法获取邮政编码(邮政编码)。我可以获取当前城市,但是当我尝试获取邮政编码时,它给了我一个空指针异常。谁能帮我。
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