diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index ad03692383..2e2a405c96 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1293,7 +1293,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven protected void onStart() { super.onStart(); stopped = false; - lockHelper.onStart(); + lockHelper.onStart(this); getMyApplication().getNotificationHelper().showNotifications(); } @@ -1312,7 +1312,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven onPauseActivity(); } stopped = true; - lockHelper.onStop(); + lockHelper.onStop(this); super.onStop(); } @@ -1415,7 +1415,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven getMapView().refreshMap(true); } }); - lockHelper.refreshRouterSettings(); getMapView().refreshMap(true); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java index 320737f484..ec658b59bf 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java @@ -1,5 +1,6 @@ package net.osmand.plus.helpers; +import android.app.Activity; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; @@ -58,6 +59,8 @@ public class LockHelper implements SensorEventListener { unlockEvent(); } }; + + refreshRouterSettings(); } private void releaseWakeLocks() { @@ -144,12 +147,18 @@ public class LockHelper implements SensorEventListener { setSensor(isSensorEnabled); } - public void onStart() { - setSensor(false); + public void onStart(Activity a) { + if (wakeLock == null) { + setSensor(false); + setVoiceRouterListener(false); + } } - public void onStop() { - refreshSensorSettings(); + public void onStop(Activity a) { + if(!a.isFinishing()) { + refreshRouterSettings(); + refreshSensorSettings(); + } } public void setLockUIAdapter(LockUIAdapter adapter) {