1

I'm new in android. I'm using the GooglePlaces Api in my app. I already have a key and the GooglePlace service enabled.

According to Google documentation, the correct way to build the GooglePlaces

mGoogleApiClient = new GoogleApiClient .Builder(this) .addApi(Places.GEO_DATA_API) .addApi(Places.PLACE_DETECTION_API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build();

But looking for code examples on other webpages, I found:

mGoogleApiClient = new GoogleApiClient.Builder(this)
        .enableAutoManage(this, 0 /* clientId */, this)
        .addApi(Places.GEO_DATA_API)
        .build();

What is the "clientId" parameter? How do i get it? Is the same as the Google Client OAuth 2.0?

user3821381
  • 114
  • 2
  • You can use Android ReactiveLocation [Android-ReactiveLocation](https://github.com/mcharmas/Android-ReactiveLocation) > Small library that wraps Google Play Services API in brilliant RxJava > Observables reducing boilerplate to minimum. – Anderson K Oct 31 '15 at 15:49

1 Answers1

0

YES.

To create an OAuth 2.0 client ID in the Google Developers Console, do the following:

  1. Open the Credentials page.
  2. Click Create new Client ID.
  3. Select the appropriate Application Type for your project and enter any additional information required. If this is your first time creating a client ID, besides being able to select your application type, you can configure your consent screen by clicking the Consent Screen button. You will not get a prompt to configure your consent screen again after you do it the first time.
  4. Click Create Client ID

To deactivate the client ID, click the Delete button below the appropriate table on the Credentials page.

EDITS:

Don't forgot to add onStart() and onStop() in code:-

@Override
protected void onStart() {
    super.onStart();
    mGoogleApiClient.connect();
}

@Override
protected void onStop() {
    super.onStop();
    mGoogleApiClient.disconnect();
}
pRaNaY
  • 24,642
  • 24
  • 96
  • 146
  • I got a client ID like this: 1234567891234-bq5ncqm2gckhj8melh7q3deedk38hapi.apps.googleusercontent.com what is the clientID (int parameter) in the builder? .enableAutoManage(this, /* clientId */, this) The first 13 numbers are too large for a integer type. – user3821381 Oct 31 '15 at 21:08
  • can you check [using enableAutoManage() in fragment](http://stackoverflow.com/questions/30622906/using-enableautomanage-in-fragment) ? – pRaNaY Nov 03 '15 at 12:05