-1
我有可观察到的返回如下的方法:从可观测获取结果 - Kotin的Android的
fun currentLocation(): Observable<LatLngFix> {
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) != ConnectionResult.SUCCESS ||
!context.isLocationPermissionGranted()) {
return getDefaultLocation()
}
// lastKnownLocation returns location or complete without result
// in the latter case, return default unknown location
return Observable
.concat(locationProvider.lastKnownLocation.map {
val latLng = LatLngFix(it.latitude, it.longitude)
[email protected] latLng
}, getDefaultLocation())
.onErrorResumeNext { getDefaultLocation() }
.first()
}
然后当我调用这个函数,我想获得的经纬度变量。所以,我需要订阅可观察oviously,但不知道为什么,下面给出了一个错误:
localisationService.currentLocation().subscribe(latLng -> {
})
话说的latLng没有定义。什么是检索价值的正确方法?
这不是kotlin lambda函数语法。 – Christopher