Open tcqq opened 5 years ago
@mcharmas Now I use the following code to get the place address, but how should I get the place name?
private fun googleLocation() { locationProvider = ReactiveLocationProvider(applicationContext, ReactiveLocationProviderConfiguration .builder() .setRetryOnConnectionSuspended(true) .build()) val locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setNumUpdates(1) locationProvider!!.getUpdatedLocation(locationRequest) .doOnNext { latitude = it.latitude longitude = it.longitude Timber.d("latitude: $latitude longitude: $longitude") } .flatMap { location -> locationProvider!!.getReverseGeocodeObservable(location.latitude, location.longitude, 1) } .map { addresses -> if (!addresses.isEmpty()) addresses[0] else null } .map(AddressToStringFunc()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .`as`(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY))) .subscribe(DisplayTextOnViewAction(location), ErrorHandler()).isDisposed }
@mcharmas Now I use the following code to get the place address, but how should I get the place name?