I have this method to get the user location and I want to return myLocation
variable :
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location. In some rare situations this can be null.
if (location != null) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng mylocation = new LatLng(latitude, longitude);
}
}
});
I have this method inside of a function that returns a LatLng value but I can't get the value from inside of the method.