Я интегрировал новый Place SDK, предоставленный Google.
Мой метод автозаполнения приведен ниже.Как я могу получить объект Place из ответа?
private fun getPlaceAutoComplete(placesClient: PlacesClient, query: String) {
val token = AutocompleteSessionToken.newInstance()
val request = FindAutocompletePredictionsRequest.builder()
.setSessionToken(token)
.setQuery(query)
.build()
placesClient.findAutocompletePredictions(request).addOnSuccessListener { response ->
placeList.clear()// Place List is a List of Place Instances
for (prediction in response.autocompletePredictions) {
var place = prediction.getPlace()// There is no option to ge the Place.
placeList.add(place)
}
setAdapter(placeList)
}.addOnFailureListener { exception ->
if (exception is ApiException) {
Log.e(TAG, "Place not found: " + exception.statusCode)
}
}
}