我突然关闭了PlaceAutocompleteFragment。
我收到此错误Status{statusCode=ERROR, resolution=null}
我的xml布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.kiranbj.androidtcps.Main3Activity">
<fragment
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="50dp"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
</android.support.constraint.ConstraintLayout>
MyKotlin代码
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main3)
val autocompleteFragment = fragmentManager.findFragmentById(R.id.place_autocomplete_fragment) as PlaceAutocompleteFragment
val typeFilter = AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build()
autocompleteFragment.setFilter(typeFilter)
autocompleteFragment.setOnPlaceSelectedListener(this)
}
清单
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
在google_map_key文件中添加了密钥