aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-01-28 13:14:59 +0100
committerChristian Schneppe <christian@pix-art.de>2018-01-28 13:14:59 +0100
commit8b8f356274210b95c090bf56c27e4e36087a0919 (patch)
treec54b37a1be666c5f3c241cfeccee8f541f9a58c9
parenta091237b0c94178db359b942b79d3c2d1c6d753b (diff)
aaded some checks to fix some rare crashes of location services
Diffstat (limited to '')
-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() {