From 3d2692afd96b3464330221314252bef5f3a26af0 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 10 Jul 2010 08:58:10 +0000 Subject: [PATCH] fix for 2.1 android git-svn-id: https://osmand.googlecode.com/svn/trunk@312 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- OsmAnd/src/com/osmand/activities/MapActivity.java | 9 ++++++--- .../com/osmand/activities/search/SearchPOIActivity.java | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/com/osmand/activities/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java index 4b2fed15d5..3c5d75aa05 100644 --- a/OsmAnd/src/com/osmand/activities/MapActivity.java +++ b/OsmAnd/src/com/osmand/activities/MapActivity.java @@ -212,6 +212,9 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat if(prefs == null || !prefs.contains(OsmandSettings.LAST_KNOWN_MAP_LAT)){ LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); Location location = service.getLastKnownLocation(LocationManager.GPS_PROVIDER); + if(location == null){ + location = service.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + } if(location != null){ mapView.setLatLon(location.getLatitude(), location.getLongitude()); mapView.setZoom(14); @@ -606,14 +609,14 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); service.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this); - LocationProvider prov = service.getProvider(LocationManager.GPS_PROVIDER); - if(!service.isProviderEnabled(LocationManager.GPS_PROVIDER) && !isRunningOnEmulator()){ + if(!isRunningOnEmulator()){ + // try to always ask for network provide it is faster way to find location service.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this); - prov = service.getProvider(LocationManager.NETWORK_PROVIDER); currentLocationProvider = LocationManager.NETWORK_PROVIDER; } else { currentLocationProvider = LocationManager.GPS_PROVIDER; } + LocationProvider prov = service.getProvider(currentLocationProvider); providerSupportsBearing = prov == null ? false : prov.supportsBearing() && !isRunningOnEmulator(); providerSupportsSpeed = prov == null ? false : prov.supportsSpeed() && !isRunningOnEmulator(); diff --git a/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java index e236497ed4..5a8e01a7a8 100644 --- a/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java @@ -281,9 +281,12 @@ public class SearchPOIActivity extends ListActivity implements LocationListener, if (searchNearBy) { LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); service.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this); - if (!isRunningOnEmulator() && !service.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + if(!isRunningOnEmulator()){ + // try to always ask for network provide it is faster way to find location service.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this); currentLocationProvider = LocationManager.NETWORK_PROVIDER; + } else { + currentLocationProvider = LocationManager.GPS_PROVIDER; } } }