Skip to content

Commit

Permalink
added exception handling for devices where certain providers may not …
Browse files Browse the repository at this point in the history
…be available
  • Loading branch information
tobykurien committed Jan 22, 2015
1 parent 6359999 commit 0d2c636
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions app/src/main/java/com/SecUpwN/AIMSICD/service/LocationTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,27 @@ public class LocationTracker {

public void start() {
lastKnownLocation();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_MIN_UPDATE_TIME,
GPS_MIN_UPDATE_DISTANCE, mLocationListener);
lm.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, GPS_MIN_UPDATE_TIME,
GPS_MIN_UPDATE_DISTANCE, mLocationListener);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, GPS_MIN_UPDATE_TIME,
GPS_MIN_UPDATE_DISTANCE, mLocationListener);

try {
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_MIN_UPDATE_TIME,
GPS_MIN_UPDATE_DISTANCE, mLocationListener);
} catch (IllegalArgumentException e) {
// provider doesn't exist, so ignore
}

try {
lm.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, GPS_MIN_UPDATE_TIME,
GPS_MIN_UPDATE_DISTANCE, mLocationListener);
} catch (IllegalArgumentException e) {
// provider doesn't exist, so ignore
}

try {
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, GPS_MIN_UPDATE_TIME,
GPS_MIN_UPDATE_DISTANCE, mLocationListener);
} catch (IllegalArgumentException e) {
// provider doesn't exist, so ignore
}
}

public void stop() {
Expand Down

0 comments on commit 0d2c636

Please sign in to comment.