Kartheek
Kartheek

Reputation: 7214

Google Places API for Android not showing

We are not able to see Google Places API for Android in the Google API services list. we are switching an app to a new google account, so we are enabling all the existing services in the new account where are not able to find the Google Places API for Android.
We need to enable Google Places API for Android into the new account to support the existing customers until we do the migration.
Can you please help us on this?

Upvotes: 0

Views: 1784

Answers (1)

Manish Ahire
Manish Ahire

Reputation: 580

According to Google new policy "Deprecation notice: Google Play Services version of the Places SDK for Android"

Notice: The Google Play Services version of the Places SDK for Android (in Google Play Services 16.0.0) is deprecated as of January 29, 2019, and will be turned off on July 29, 2019. A new version of the Places SDK for Android is now available. We recommend updating to the new version as soon as possible. For details, see the migration guide. Google Place Autocomplete

Add the Gradle Dependancy

implementation 'com.google.android.libraries.places:places:1.0.0'

Initialize the Place API

Places.initialize(getApplicationContext(), "YOUR_API_KEY");

Start the Autocomplete Intent

List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME);
    Intent intent = new Autocomplete.IntentBuilder(
            AutocompleteActivityMode.OVERLAY, fields)
            .build(this);
    startActivityForResult(intent, 1101);

onActivityResult

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == request_code) {
        if (resultCode == RESULT_OK) {
            Place place = Autocomplete.getPlaceFromIntent(data);
            Log.i(TAG, "ManishPlace: " + place.getName() + ", " + place.getId());
            txt_search.setText(place.getName());
        } else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
            // TODO: Handle the error.
            Status status = Autocomplete.getStatusFromIntent(data);
            Log.i(TAG, status.getStatusMessage());
        } else if (resultCode == RESULT_CANCELED) {
            // The user canceled the operation.
        }
    }
}

Or Follow the my GitHub Tutorial

Google Place Search GitHub Repository

Upvotes: 1

Related Questions