Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c575734 authored by Ethan Chen's avatar Ethan Chen
Browse files

Fix uncaught exception when no location provider available

Change-Id: I2625e6d219401a04a372a487d84edaaf3099f0d6
parent da62675d
Loading
Loading
Loading
Loading
+21 −16
Original line number Diff line number Diff line
@@ -253,6 +253,7 @@ public class LookupProvider extends ContentProvider {
        LocationManager locationManager = (LocationManager)
                getContext().getSystemService(Context.LOCATION_SERVICE);

        try {
            locationManager.requestSingleUpdate(new Criteria(),
                    new LocationListener() {
                @Override
@@ -273,6 +274,10 @@ public class LookupProvider extends ContentProvider {
            }, Looper.getMainLooper());

            return locationManager.getLastLocation();
        } catch (IllegalArgumentException e) {
            // If no location service exists, IllegalArgument exception is thrown
            return null;
        }
    }

    /**