diff --git a/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java b/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java index f796126a3..abe2eefd5 100644 --- a/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java @@ -483,13 +483,16 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa @Override public void onLocationPermissionGranted() { fr.free.nrw.commons.location.LatLng currLocation = locationManager.getLastLocation(); - final CameraPosition position; - position = new CameraPosition.Builder() - .target(new com.mapbox.mapboxsdk.geometry.LatLng(currLocation.getLatitude(), currLocation.getLongitude(), 0)) // Sets the new camera position - .zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level - .build(); + if (currLocation != null) { + final CameraPosition position; + position = new CameraPosition.Builder() + .target(new com.mapbox.mapboxsdk.geometry.LatLng(currLocation.getLatitude(), + currLocation.getLongitude(), 0)) // Sets the new camera position + .zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level + .build(); - mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000); + mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000); + } } }); locationPermissionsHelper.handleLocationPermissions(locationAccessDialog, locationOffDialog);