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 f796126a32..abe2eefd5d 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 void onLocationPermissionDenied(String toastMessage) { @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(); - - mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000); + 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); + } } }); locationPermissionsHelper.handleLocationPermissions(locationAccessDialog, locationOffDialog);