关键词:
【中文标题】Google Places API Android:自动完成关闭太快【英文标题】:Google Places API Android: Autocompletion closes too quickly 【发布时间】:2017-04-01 03:46:53 【问题描述】:我在我的 Android 应用中添加了地方自动完成功能。当我单击一个按钮 (chooseLocationButton
) 时,它会正确打开自动完成小部件。问题是当我想在搜索字段中写一个名字时。单击第一次击键后,自动完成小部件立即关闭,研究尚未完成。
这是它在运行控制台中所写的:
W/IInputConnectionWrapper: reportFullscreenMode on inexistent 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(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?
当然,我已经在 Google Developer Console 中启用了 Google Places android API 和 Google Map android API。 我还向 AndroidManifest.xml 添加了 API 密钥,如下所示:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
在日志中我观察到:
BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/placesandroid/v1/getAutocompletePredictions...
后跟:
[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
在 Android Studio 的运行日志中我有:PLACES_API_KEY_EXPIRED
我希望有人可以帮助我。
谢谢。
【问题讨论】:
你在manifest的application标签中定义了key吗? 是的,它是在应用程序标签@kgandroid中定义的 【参考方案1】:这听起来确实是一个关键问题。需要仔细检查的事项:
密钥是 Android 密钥,而不是网络密钥。 key上的包名restrict实际上和你应用的包名一致,为signed correctly。 您没有超过每天 1000 个请求的限制。【讨论】:
我添加了我在 Google API 控制台中创建的 API 密钥。我使用“Android 应用程序”来限制它,这是我在 AndroidManifest.xml 和 SHA-1 顶部找到的包名称(与您与我共享的网站相同)。每天的请求数量远远超过 1000 个限制@AndrewR【参考方案2】:当我注意到 Google 为 API 密钥创建了一个 .xml 文件并与我放入 string.xml 中的 API 产生冲突时,问题就解决了
【讨论】:
【参考方案3】:更改 API 密钥解决了我的问题。
您可以从here 生成新密钥
【讨论】:
获取适用于 Android 的 Google Places API 密钥
】获取适用于Android的GooglePlacesAPI密钥【英文标题】:GettingGooglePlacesAPIkeyforAndroid【发布时间】:2016-03-2710:37:17【问题描述】:在过去的一周里,我一直在尝试为android实现GooglePlacesAPI,Google的开发者页面说我需要一个api密钥,在... 查看详情
适用于 Android 的 Google Places API:地图立即消失
】适用于Android的GooglePlacesAPI:地图立即消失【英文标题】:GooglePlacesAPIforAndroid:Mapsvanishinginstantly【发布时间】:2016-05-3003:38:23【问题描述】:我正在使用以下代码通过GooglePlacesAPIforAndroid在我的应用程序上显示地图:publicvoidshowMa... 查看详情
Google Places API Android:自动完成关闭太快
】GooglePlacesAPIAndroid:自动完成关闭太快【英文标题】:GooglePlacesAPIAndroid:Autocompletionclosestooquickly【发布时间】:2017-04-0103:46:53【问题描述】:我在我的Android应用中添加了地方自动完成功能。当我单击一个按钮(chooseLocationButton)时... 查看详情
Google Places API 总是返回错误
...【发布时间】:2015-05-0504:55:35【问题描述】:我已在我的android应用程序中集成了GooglePlacesAPI。我已经阅读了api文档SeeHere。我已经为android激活了GooglePlacesApi并生成了浏览器密钥当我调用api时得到错误响应-"error_message":"Th 查看详情
Android Google Places API - PlaceAutocompleteFragment 清除按钮监听器
】AndroidGooglePlacesAPI-PlaceAutocompleteFragment清除按钮监听器【英文标题】:AndroidGooglePlacesAPI-PlaceAutocompleteFragmentclearbuttonlistener【发布时间】:2016-07-0722:09:16【问题描述】:我在我的项目中使用GooglePlacesAPIforAndroid-PlaceAutocompleteFragme 查看详情
如何为我的 Android 应用获取 Google Places API 密钥
】如何为我的Android应用获取GooglePlacesAPI密钥【英文标题】:HowdoIgetaGooglePlacesAPIkeyformyAndroidApp【发布时间】:2014-08-0918:35:00【问题描述】:在过去的48小时里,我一直在努力寻找这个问题的答案。问这个问题的人:howcanImakeAPIKEYfor... 查看详情
Google Places API Autocomplete 仅获取城市列表
...【发布时间】:2019-01-2704:08:05【问题描述】:我正在我的Android应用程序上实现google的地点自动完成功能,它可以显示每个类似的地点,但是只有当用户尝试搜索任何内容时,我才能获得城市建议。我进行了很多搜索,但无法找... 查看详情
即使使用正确的 API 密钥,Android 自动完成的 Google Places API 请求也会被拒绝
】即使使用正确的API密钥,Android自动完成的GooglePlacesAPI请求也会被拒绝【英文标题】:GooglePlacesAPIrequestdeniedforAndroidautocomplete,evenwiththerightapikey【发布时间】:2013-01-1706:21:14【问题描述】:我正在尝试使用本教程中描述的GooglePlac... 查看详情
使用适用于 android 的 google places api 网络服务搜索特定的附近地点
】使用适用于android的googleplacesapi网络服务搜索特定的附近地点【英文标题】:Searchspecificnearbyplacesusinggoogleplacesapiwebservicesforandroid【发布时间】:2016-02-2613:34:32【问题描述】:我正在尝试使用googleplacesapi网络服务将地点搜索类型... 查看详情
如何从 Android/Java 中的 Google Places API 获取有关地点的确切子类别名称? [复制]
】如何从Android/Java中的GooglePlacesAPI获取有关地点的确切子类别名称?[复制]【英文标题】:HowcanIgetexactsubcategorynameaboutaplacefromGooglePlacesAPIinAndroid/Java?[duplicate]【发布时间】:2020-11-2114:30:16【问题描述】:看这个截图:image如果您仔... 查看详情
在 Android Studio 中使用 Google Places API 时找不到汽车修理店/车库/汽车店
】在AndroidStudio中使用GooglePlacesAPI时找不到汽车修理店/车库/汽车店【英文标题】:Can\'tfindCar-repair/garage/motorshopswhileusingGooglePlacesAPIinAndroidStudio【发布时间】:2020-08-2706:42:42【问题描述】:publicvoidonMapReady(GoogleMapgoogleMap)mMap=googleMap 查看详情
Google 是不是采取了措施来防止恶意 Places API 滥用?
...5-1009:21:30【问题描述】:我有一个使用PlacesAutoCompleteAPI的Android应用。现在,谷歌收取$x/request 查看详情
反应:Google Places API/ Places 详细信息
】反应:GooglePlacesAPI/Places详细信息【英文标题】:React:GooglePlacesAPI/PlacesDetails【发布时间】:2017-12-3005:41:47【问题描述】:我有以下代码,它基于GooglePlacesAPI检索GooglePlaces评论。我已经将逻辑合并为React生命周期组件。目前,我... 查看详情
新的 Google API 密钥“Google Maps API v3”不适用于 Google Places API?
】新的GoogleAPI密钥“GoogleMapsAPIv3”不适用于GooglePlacesAPI?【英文标题】:NewGoogleAPIKey"GoogleMapsAPIv3"doesn\'tworkforGooglePlacesAPI?【发布时间】:2012-08-3108:14:40【问题描述】:我正在使用GooglePlacesAPI(https://developers.google.com/places 查看详情
使用 Google Places Autocomplete API 时空间不工作
...【发布时间】:2013-11-1623:12:51【问题描述】:当我在我的Android应用中输入空格时,我的下拉菜单中不再显示任何结果。我怎样才能解决这个问题?我正在对输入进行编码,所以我不确定它为什么不起作用...空格前:空格后:我... 查看详情
Google Places API 与 Google Geocode API
】GooglePlacesAPI与GoogleGeocodeAPI【英文标题】:GooglePlacesAPIvs.GoogleGeocodeAPI【发布时间】:2014-03-1823:36:01【问题描述】:我已经使用自动完成功能和GoogleGeocodingApi实现了GooglePlacesAPI。问题是结果似乎无法正常工作。有时从自动完成列... 查看详情
使用 google-places-api 的简单 html 页面的 ApiNotActivatedMapError
】使用google-places-api的简单html页面的ApiNotActivatedMapError【英文标题】:ApiNotActivatedMapErrorforsimplehtmlpageusinggoogle-places-api【发布时间】:2016-06-1212:42:16【问题描述】:我正在尝试创建一个包含google-places-api的简单html页面(稍后我想... 查看详情
Google Places API 结果与 Google 搜索不匹配
】GooglePlacesAPI结果与Google搜索不匹配【英文标题】:GooglePlacesAPIresultsdonotmatchGooglesearch【发布时间】:2014-10-2403:40:57【问题描述】:在我的数据中,我发现了许多类似以下的示例。如果您在Google上搜索“CheyneyUniversityPA”,您会得... 查看详情