Why is FusedLocationApi.getLastLocation null

The fused location provider will only maintain background location if at least one client is connected to it. Now just turning on the location service will not guarantee storing the last known location. Once the first client connects, it will immediately try to get a location. If your activity is the first client to connect … Read more

Android LocationServices.FusedLocationApi deprecated

Original Answer This is happening because FusedLocationProviderApi deprecated in a recent version of google play services. You can check it here. The official guide now suggests using FusedLocationProviderClient. You can find the detailed guide here. for e.g inside onCreate() or onViewCreated() create a FusedLocationProviderClient instance Kotlin val fusedLocationClient = LocationServices.getFusedLocationProviderClient(requireContext()) and for requesting the last … Read more

How to get current Location in GoogleMap using FusedLocationProviderClient

This is similar to my other answer here, updated to use the recently introduced FusedLocationProviderClient class. In order to use a FusedLocationProviderClient in conjunction with a Google Map: Wait until the Google Map is ready Request the Location permission at runtime if needed Request location updates once the permission is granted Update the Google Map … Read more

Blue dot and circle is not shown on MyLocation using android fused location api

For targeting api-23 or higher See this answer…. For targeting api-22 and lower: This code works for me, it has the MyLocation blue dot/circle, and it also places a Marker on the current location using the Fused Location Provider. Here is the entire Activity code I used: import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; … Read more

Fused Location always returns null

Add this code to your onConnected, thats where it would get Last Known Location. private static Location mLastLocation; private static GoogleApiClient mGoogleApiClient; private static Context context; // added private LocationRequest mLocationRequest; private Double latitude; private Double longitude; private String TAG = “”; // set your TAG @Override public void onConnected(Bundle bundle) { if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) … Read more