diff --git a/auth/README.md b/auth/README.md index abff5d9d4..c3a36d870 100644 --- a/auth/README.md +++ b/auth/README.md @@ -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. } ```