Ich versuche Google Maps zu verwenden. Ich habe diesen Code:addressList Größe ist 0 Google Maps
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.getUiSettings().setZoomControlsEnabled(true);
List <Address> addressList = null;
if (location != null || !location.equals("")){
Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);
}catch (IOException e){
e.printStackTrace();
}
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title(location));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
}
}
Ich aber nehme dies: Address Größe 0. Fehler "java.lang.IndexOutOfBoundsException: Ungültige Index 0, Größe 0" Lage meine Variable ist aber funktioniert gut. Was mache ich falsch? Danke vielmals.
Vielen Dank! Es war auch ein Fehler von meinem Emulator, danke! –