In android there are two separate functions to get Location:
getLastLocation returns the last known location of the device where, getCurrentLocation returns current location of the device by finding latest (current) location. getCurrentLocation takes some time to calculate where getLastLocation does not take any time.
In Huawei Location Kit, I found fusedLocation callback for location and getLastLocation(). Is there any method to get Current Location as in android. And what is the best way to get exact location of the device?
You are advised to use requestLocationUpdates
to get current location information,
In the callback function, you will get the locationResult.
Then you can get the location information by locationResult.getLocations()
interface, like below:
private final LocationCallback mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
Log.d(TAG, "onLocationResult: " + locationResult);
Location location = locationResult.getLastLocation();
updateLocationLister(location);
}