Google Places API Android:自动填充过快关闭

Bas*_*hen 6 android google-maps autocomplete google-places-api

我在我的Android应用程序中添加了Place Autocompletion.当我单击按钮(chooseLocationButton)时,它会正确打开自动完成小部件.问题是我想在搜索字段中写一个名字.点击第一次击键后,自动完成小部件关闭,研究没有完成.这是它在Run控制台中编写的内容:

W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
Run Code Online (Sandbox Code Playgroud)

这是代码:

AutocompleteFilter.Builder a = new AutocompleteFilter.Builder();
    try {
        final Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
                .setFilter(a.setTypeFilter(AutocompleteFilter.TYPE_FILTER_REGIONS).build())
                .build(this);
        chooseLocationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
            }
        });
    } catch (GooglePlayServicesRepairableException e) {
        e.printStackTrace();
        // TODO handle exception!
    } catch (GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
        // TODO handle exception! Toast?
    }
Run Code Online (Sandbox Code Playgroud)

当然,我已经在Google Developer Console中启用了Google Places Android API和Google Map android API.此外,我已将API密钥添加到AndroidManifest.xml中,如下所示:

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />
Run Code Online (Sandbox Code Playgroud)

在日志中我观察到:

BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/placesandroid/v1/getAutocompletePredictions...
Run Code Online (Sandbox Code Playgroud)

其次是:

[67738] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/placesandroid/v1/getAutocompletePredictions?key=...11-17 21:02:01.207 1053-1543/? E/Places: PLACES_API_INVALID_APP
Run Code Online (Sandbox Code Playgroud)

在Android Studio的运行日志中,我有: PLACES_API_KEY_EXPIRED

我希望有人可以帮助我.

谢谢.

Bas*_*hen 2

当我注意到 Google 为 API 密钥创建了一个 .xml 文件并且与我放入 string.xml 中的 API 发生冲突时,问题就解决了