[英]Google places API for android showing statusCode=ERROR_OPERATION_FAILED
[英]ERROR_OPERATION_FAILED Status Code on using Google Places Api in Android
我正在使用本教程来创建自动完成搜索框。 我创建了一个自定义适配器来填充我的自动完成文本框。
mGoogleApiClient = new GoogleApiClient.Builder(ActivityMap.this)
.addApi(Places.GEO_DATA_API)
.enableAutoManage(this, GOOGLE_API_CLIENT_ID, this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient,
constraint.toString(),
mBounds, null);
但是,我收到以下错误消息,如下所示:
{statusCode=ERROR_OPERATION_FAILED, resolution=null}
适配器的getPredictions方法中的以下代码行
final Status status = autocompletePredictions.getStatus();
if (!status.isSuccess()) {
Toast.makeText(getContext(), "Error: " + status.toString(),
Toast.LENGTH_SHORT).show();
Log.e(TAG, "Error getting place predictions: " + status.toString());
autocompletePredictions.release();
return null;
}
PS:在行中:
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mPlaceFilter);
我试图将mPlaceFilter更改为null,以得到相同的结果
最后,弄清楚了。 我在Android清单中编写了另一个API密钥。
另外,如果您将Google API密钥用于多个应用程序,请仅指定一次密钥(使用Android教程设置指南),并在同一项目中启用对其他API的支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.