Merge pull request #176 from misaochan/illegal-arg-exception

Catch Illegal Argument Exceptions
This commit is contained in:
Nicolas Raoul 2016-07-12 13:26:48 +09:00 committed by GitHub
commit a7427f21bf

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);
}
}