Skip to content

Update README.md #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,38 @@ startActivityForResult(

#### Handling the sign-in response

The authentication flow provides only two response codes:
`Activity.RESULT_OK` if a user is signed in, and `Activity.RESULT_CANCELLED` if
sign in failed. No further information on failure is provided as it is not
The authentication flow only provides three response codes:
`Activity.RESULT_OK` if a user is signed in, `Activity.RESULT_CANCELLED` if
sign in failed, and `ResultCodes.RESULT_NO_NETWORK` if sign in failed due to a lack of network connectivity.
No further information on failure is provided as it is not
typically useful; the only recourse for most apps if sign in fails is to ask
the user to sign in again later, or proceed with an anonymous account if
supported.

```java
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
if (resultCode == RESULT_OK) {
// user is signed in!
startActivity(new Intent(this, WelcomeBackActivity.class));
finish();
} else {
// user is not signed in. Maybe just wait for the user to press
// "sign in" again, or show a message
}
}
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
// user is signed in!
startActivity(new Intent(this, WelcomeBackActivity.class));
finish();
return;
}

// Sign in cancelled
if (resultCode == RESULT_CANCELED) {
showSnackbar(R.string.sign_in_cancelled);
return;
}

// No network
if (resultCode == ResultCodes.RESULT_NO_NETWORK) {
showSnackbar(R.string.no_internet_connection);
return;
}

// User is not signed in. Maybe just wait for the user to press
// "sign in" again, or show a message.
}
```

Expand Down