【发布时间】:2018-08-27 20:25:50
【问题描述】:
我有这个方法来获取用户位置,我想返回myLocation变量:
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);
}
}
});
我在返回 LatLng 值的函数内部有这个方法,但我无法从方法内部获取值。
【问题讨论】:
-
在此处输入您的完整方法。我记住位置是一项服务,你必须处理你的代码取决于回调事件
-
@AbuQauod 完整的方法已经存在
-
为此使用广播接收器或总线。
-
@SaurabhVadhva我不能使用它,因为我需要位置然后我调用函数