diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index 3be87954b3..d2bb39805f 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -144,6 +144,9 @@ public class NavigationService extends Service implements LocationListener { LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); try { locationManager.requestLocationUpdates(serviceOffProvider, 0, 0, NavigationService.this); + } catch (SecurityException e) { + Toast.makeText(this, R.string.no_location_permission, Toast.LENGTH_LONG).show(); + Log.d(PlatformUtil.TAG, "Location service permission not granted"); //$NON-NLS-1$ } catch (IllegalArgumentException e) { Toast.makeText(this, R.string.gps_not_available, Toast.LENGTH_LONG).show(); Log.d(PlatformUtil.TAG, "GPS location provider not available"); //$NON-NLS-1$ @@ -202,7 +205,11 @@ public class NavigationService extends Service implements LocationListener { usedBy = 0; // remove updates LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); - locationManager.removeUpdates(this); + try { + locationManager.removeUpdates(this); + } catch (SecurityException e) { + Log.d(PlatformUtil.TAG, "Location service permission not granted"); //$NON-NLS-1$ + } if (!isContinuous()) { WakeLock lock = getLock(this); @@ -225,7 +232,11 @@ public class NavigationService extends Service implements LocationListener { if (!isContinuous()) { // unregister listener and wait next time LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); - locationManager.removeUpdates(this); + try { + locationManager.removeUpdates(this); + } catch (SecurityException e) { + Log.d(PlatformUtil.TAG, "Location service permission not granted"); //$NON-NLS-1$ + } WakeLock lock = getLock(this); if (lock.isHeld()) { lock.release();