From 6d7a01ed9d3b529cdcf68a52df8f22194befec72 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 7 May 2010 13:42:33 +0000 Subject: [PATCH] introduce wake lock git-svn-id: https://osmand.googlecode.com/svn/trunk@47 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- OsmAnd/AndroidManifest.xml | 1 + OsmAnd/src/com/osmand/activities/MapActivity.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 00f1161be1..2fd0928ef9 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -28,4 +28,5 @@ + \ No newline at end of file diff --git a/OsmAnd/src/com/osmand/activities/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java index 10e4775a66..54e6ec2a9f 100644 --- a/OsmAnd/src/com/osmand/activities/MapActivity.java +++ b/OsmAnd/src/com/osmand/activities/MapActivity.java @@ -11,6 +11,8 @@ import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.os.Bundle; +import android.os.PowerManager; +import android.os.PowerManager.WakeLock; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -47,6 +49,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat private PointLocationLayer locationLayer; private POIMapLayer poiMapLayer; + private WakeLock wakeLock; protected void onRestoreInstanceState(Bundle savedInstanceState) { @@ -178,7 +181,10 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat edit.putFloat(KEY_LAST_LON, (float) mapView.getLongitude()); edit.putInt(KEY_LAST_ZOOM, mapView.getZoom()); edit.commit(); - + if (wakeLock != null) { + wakeLock.release(); + wakeLock = null; + } } @Override @@ -196,6 +202,12 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat } LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); service.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, this); + + if (wakeLock == null) { + PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); + wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "com.osmand.map"); + wakeLock.acquire(); + } }