I am learning getting location with Google Service API. But I am getting confused since I saw people use two ways to get location:
1.
FusedLocationProviderApi fusedLocationProviderApi = LocationServices.FusedLocationApi;
Location lastKnownLocation = fusedLocationProviderApi.getLastLocation(googleApiClient);
2.
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
...
Task<Location> locationTask = mFusedLocationClient.getLastLocation();
locationTask.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location
if (location != null) {
mLastKnownLocation = location;
}
}
});
Could someone please explain to me when to use which one & what are the differences between these two approaches to get last known location?