I'm currently adding google places autocomplete to my project. The document says that we should use the newest google places API and use a different library. I already followed the document's tutorial properly. I'm using autocomplete overlay mode on AppCompatActivity. It's definitely working but there are bugs that I found. first, when I type a place name completely lets saying "Bali", it shows an empty list but when I type "Ba" it shows a list of places that contains the name "Ba". second, after I click on the suggested list, the fragment doesn't close and keep searching the same name of places.

I've tried to use a different way. I tried to use intent and stuff. it's working too but it shows the same errors.

Here's the code I've been working on :

if (!Places.isInitialized()) { Places.initialize(applicationContext, resources.getString(R.string.google_maps_key)) }

    placesClient = Places.createClient(this)

    autocompleteSupportFragment = supportFragmentManager.findFragmentById(R.id.autocomplete_fragment) as AutocompleteSupportFragment?
    autocompleteSupportFragment?.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME))
    autocompleteSupportFragment?.setLocationBias(RectangularBounds.newInstance(LAT_LNG_BOUNDS))

    autocompleteSupportFragment?.setOnPlaceSelectedListener(object : PlaceSelectionListener {
        override fun onPlaceSelected(place: Place) {
            mGoogleMap!!.addMarker(MarkerOptions().position(place.latLng!!).title(place.name.toString()))
            mGoogleMap?.animateCamera(CameraUpdateFactory.newLatLngZoom(place.latLng, 14f))
        }

        override fun onError(status: Status) {
        }
    })

I expected when I click on the result, the fragment will close and it will set the text of the fragment. But the fragment doesn't close and always keep searching the same place. Any recommendation for me how to use this API properly? cause it seems that are bugs of this API

0 Answers