I'm having problems with Android Google Places API - auto complete feature. I use the same key that i used for Android Google Maps API (and in the documentation, it is written this is ok). Here is my definition in manifest:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="mykey"/>
But getAutocompletePredictions returns 'PLACES_API_ACCESS_NOT_CONFIGURED' message as status.
Here is my Java code:
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(context)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
googleApiClient.connect();
LatLngBounds latLngBounds = new LatLngBounds.Builder().
include(SphericalUtil.computeOffset(latlon, RADIUS, 0)).
include(SphericalUtil.computeOffset(latlon, RADIUS, 90)).
include(SphericalUtil.computeOffset(latlon, RADIUS, 180)).
include(SphericalUtil.computeOffset(latlon, RADIUS, 270)).build();
PendingResult<AutocompletePredictionBuffer> result = Places.GeoDataApi.getAutocompletePredictions(googleApiClient, constraint.toString(), latLngBounds, null);
AutocompletePredictionBuffer autocompletePredictions = result.await(Config.DATA_TIMEOUT, TimeUnit.MILLISECONDS);
Status status = autocompletePredictions.getStatus();
if (status.isSuccess()) {
Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();
while (iterator.hasNext()) {
AutocompletePrediction prediction = iterator.next();
//... do stuff here ...
}
}
else {
Log.d(TAG, status.getStatusMessage());
}
autocompletePredictions.release();
googleApiClient.disconnect();
Thanks in advance
Enable the Google Places API for Android in developers console and check on the credentials page that your key is still present