Add try catch block

This commit is contained in:
misaochan 2016-07-12 16:22:19 +12:00
parent 731c2024f3
commit 9b8a74b88e

View file

@ -57,10 +57,14 @@ public class GPSExtractor {
provider = locationManager.getBestProvider(criteria, true);
myLocationListener = new MyLocationListener();
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
myLocationListener.onLocationChanged(location);
try {
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
myLocationListener.onLocationChanged(location);
}
} catch (IllegalArgumentException e){
Log.e(TAG, "Illegal argument exception", e);
}
}