Plus.Peopleapi cannot connect

Asked

Viewed 27 times

1

I am developing an application that will create, read and update some documents on Drive.

In the NavigationView, I would like to identify the User’s account. The same way it’s done in the Google Play or the Play Music.

For this, I added / enabled the Google+ api and tried to collect the information as follows:

mClient = new GoogleApiClient.Builder(this).enableAutoManage(this, this).addApi(Drive.API).addApi(Plus.API).addScope(Drive.SCOPE_FILE).addScope(new Scope(Scopes.PLUS_ME)).addScope(new Scope(Scopes.PLUS_ME)).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();

@Override
public void onConnected(@Nullable Bundle bundle) {
    connectPeople();
}

private void connectPeople(){
    final PendingResult<People.LoadPeopleResult> people = Plus.PeopleApi.loadVisible(mClient, null);
    people.setResultCallback(new ResultCallback<People.LoadPeopleResult>() {
        @Override
        public void onResult(@NonNull People.LoadPeopleResult peopleData) {
            if (peopleData.getStatus().getStatusCode() == CommonStatusCodes.SUCCESS) {
                PersonBuffer personBuffer = peopleData.getPersonBuffer();
                try {
                    int count = personBuffer.getCount();
                    for (int i = 0; i < count; i++) {
                        Log.d("PEOPLE" , "Display name: " + personBuffer.get(i).getDisplayName());
                    }
                } finally {
                    personBuffer.release();
                }
            } else {
                Log.e("ERROR RRRR", peopleData.getStatus().toString());
                Toast.makeText(getApplicationContext(), "No connect: "+peopleData.getStatus().toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
}

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
        }
    } else {
        Toast.makeText(this, connectionResult.getErrorMessage(), Toast.LENGTH_LONG).show();
    }
}

Permissions:

android:name="android.permission.INTERNET"
 android:name="android.permission.USE_CREDENTIALS" 
 android:name="android.permission.GET_ACCOUNTS" 
 android:name="android.permission.READ_PROFILE"
 android:name="android.permission.ACCESS_NETWORK_STATE"
 android:name="android.permission.AUTHENTICATE_ACCOUNTS"
 android:name="android.permission.GET_ACCOUNTS"
 android:name="android.permission.ACCESS_FINE_LOCATION" 
 android:name="android.permission.ACCESS_COARSE_LOCATION" 

I added the Api’s and created the key.

I added the file google-services.json

And added the string google_app_id

Every time I make the request the following error occurs:

E/ERROR RRRR: Status{statusCode=NETWORK_ERROR, Resolution=null}

Does anyone know what it can be?

  • 1

    From what I read on the Internet, looks like this API only works on a properly signed APK and a key that matches the one registered on your Google developer console. Have you looked at that?

  • I guess we’re just missing the part: in a duly signed APK tried only in debug. I will test and inform ! Thanks!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.