Google Places API Android:自动完成关闭得太快 [英] Google Places API Android: Autocompletion closes too quickly
问题描述
我在我的android应用程序中添加了放置自动完成。当我点击一个按钮( chooseLocationButton
)时,它会正确打开Autocomplete小部件。问题是当我想在搜索字段中写一个名字时。直接点击第一次击键后,自动填充小部件关闭,研究未完成。
这里是它在运行控制台中写的内容:
W / IInputConnectionWrapper:reportFullscreenMode对不存在的InputConnection
W / IInputConnectionWrapper:finishComposingText on inactive InputConnection
这是代码:
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(这个);
chooseLocationButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
startActivityForResult(intent,PLACE_AUTOCOMPLETE_REQUEST_CODE);
}
});
} catch(GooglePlayServicesRepairedException e){
e.printStackTrace();
// TODO处理异常!
} catch(GooglePlayServicesNotAvailableException e){
e.printStackTrace();
// TODO处理异常!吐司?
}
当然,我已启用Google Places android API和Google Map android API Google开发者控制台。
另外我已经将API密钥添加到AndroidManifest.xml中,如下所示:
< meta-data
android:name =com.google.android.geo.API_KEY
android:value =@ string / google_maps_key/>
在日志中我观察到这一点:
BasicNetwork.performRequest:用于https://www.googleapis.com/placesandroid/v1/getAutocompletePredictions的意外响应代码400 ...
接下来是:
[67738] BasicNetwork.performRequest: https://www.googleapis.com/placesandroid/v1/getAutocompletePredictions?key=...11-17 21:02:01.207 1053-1543 /?意外的响应代码403 E / Places:PLACES_API_INVALID_APP
在Android Studio的运行日志中,我有: PLACES_API_KEY_EXPIRED
我希望有人能帮助我。
谢谢。
当我注意到Google为API密钥创建了一个.xml文件并且与我放入string.xml中的API
I added Place Autocompletion to my android app. When I click a button (chooseLocationButton
) it opens the Autocomplete widget correctly. The problem is when I want to write a name in the search field. Directly after clicked on the first keystroke, the Autocomplete widget close and the research is not done.
Here it is what it is written in the Run console:
W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
Here it is the code:
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?
}
Of course I have enabled Google Places android API and Google Map android API in the Google Developer Console. Also I have added the API key to the AndroidManifest.xml like that:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
In the log I observe this:
BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/placesandroid/v1/getAutocompletePredictions...
Followed by:
[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
In the Run Log of Android Studio I have: PLACES_API_KEY_EXPIRED
I hope somebody can help me.
Thank you.
The problem was solved when I noticed that Google had created an .xml file for the API key and that created a conflict with the API that I put in the string.xml
这篇关于Google Places API Android:自动完成关闭得太快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!