aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/ui/LocationActivity.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/LocationActivity.java b/src/main/java/de/pixart/messenger/ui/LocationActivity.java
index 74e2b45f9..6389fa7d4 100644
--- a/src/main/java/de/pixart/messenger/ui/LocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/LocationActivity.java
@@ -31,13 +31,19 @@ public abstract class LocationActivity extends Activity implements LocationListe
} catch (final UnsupportedOperationException ignored) {
}
}
-
- locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, Config.LOCATION_FIX_TIME_DELTA, Config.LOCATION_FIX_SPACE_DELTA, this);
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, Config.LOCATION_FIX_TIME_DELTA, Config.LOCATION_FIX_SPACE_DELTA, this);
-
+ if (locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)
+ && locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
+ locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, Config.LOCATION_FIX_TIME_DELTA, Config.LOCATION_FIX_SPACE_DELTA, this);
+ }
+ if (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)
+ && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, Config.LOCATION_FIX_TIME_DELTA, Config.LOCATION_FIX_SPACE_DELTA, this);
+ }
// If something else is also querying for location more frequently than we are, the battery is already being
// drained. Go ahead and use the existing locations as often as we can get them.
- locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, this);
+ if (locationManager.getAllProviders().contains(LocationManager.PASSIVE_PROVIDER)) {
+ locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, this);
+ }
}
protected void pauseLocationUpdates() {