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

Commit 4e93eaed authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Fallback to getLastKnownLocation

parent b44ac717
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ import android.os.Build.VERSION_CODES;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.location.LocationManagerCompat;

import java.util.concurrent.Executors;
@@ -29,7 +30,13 @@ public class FusedLocationFetcher extends LocationFetcher {
        }
    }

    @RequiresApi(api = VERSION_CODES.S)
    @SuppressLint("MissingPermission")
    private void onLocationFetched(@Nullable Location location) {
        if (location == null) {
            location = mLocationManager.getLastKnownLocation(LocationManager.FUSED_PROVIDER);
        }

        mCallback.onNewLocation(location);
    }
}