Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Google Places API, getAutocompletePredictions returns status 'PLACES_API_ACCESS_NOT_CONFIGURED'

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

like image 790
enver Avatar asked Jul 16 '15 08:07

enver


3 Answers

Enable the Google Places API for Android in developers console and check on the credentials page that your key is still present

like image 150
andrei Avatar answered Oct 24 '22 06:10

andrei


Step by step Solution that I follows :

  • Just go to https://console.developers.google.com/

  • open your project and click on Library from Left tabs

  • Now in Mobile APIs do click on Google Places API for Android and ENABLE the api

enter image description here

like image 26
Kapil Rajput Avatar answered Oct 24 '22 05:10

Kapil Rajput


I think you tried enabling Google Places API for Android

Enable this as well it works . You can found this below Google Places API for Android

Google Places API Web Service
like image 1
madhu527 Avatar answered Oct 24 '22 05:10

madhu527