This my code:
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List addresses = geocoder.getFromLocationName(text, 10);
te
I do recommend to use get the Place Id like this. It would be better than call the API directly. I stumble for this issue all day. so I hope that it would be help. who're finding the way out to get place ID from your current location. for android
Kotlin
val mPlaceDetectionClient = Places.getPlaceDetectionClient(this.context!!)
val placeResult = mPlaceDetectionClient.getCurrentPlace(null)
placeResult.addOnCompleteListener(object : OnCompleteListener{
override fun onComplete(p0: Task) {
val likelyPlaces = p0.result
if(likelyPlaces.any()){
// get the place ID from code below
placeId = likelyPlaces[0].place.id }
}
})
or if who are implementing or developing on another language such a java. you can implement your code according to a reference below.
java
https://developers.google.com/places/android-sdk/googleapi-migration