Reputation: 3467
I have an android app and I'm implementing share following these instructions.
I manage to get it working. I came back to it the next day and I get this output in logcat:
G+ on connection failed ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{422d8470: android.os.BinderProxy@422d8410}}
I have triple checked the api console, removed my OAuth clientID and input again fresh. This has not fixed it. Any idea about what I can look into to fix it?
Upvotes: 9
Views: 4382
Reputation: 3992
You can get the SIGN_IN_REQUIRED connection result for a number of reasons, eg.:
PlusClient.clearDefaultAccount();
.PlusClient.revokeAccessAndDisconnect();
.For SIGN_IN_REQUIRED, the ConnectionResult you receive contains a PendingIntent which can be used to resolve the issue. In the sample at the instructions you're following the example code handles the error in onConnectionFailed
with the following code:
@Override
public void onConnectionFailed(ConnectionResult result) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
} catch (SendIntentException e) {
mPlusClient.connect();
}
}
// Save the result and resolve the connection failure upon a user click.
mConnectionResult = result;
}
result.startResolutionForResult()
will display an account chooser or the permissions dialog to resolve the issues mentioned above, and return control to onActivityResult
, eg:
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
}
At this point the call to PlusClient.connect()
should succeed.
Upvotes: 10