@@ -199,26 +199,38 @@ startActivityForResult(
199199
200200#### Handling the sign-in response
201201
202- The authentication flow provides only two response codes:
203- ` Activity.RESULT_OK ` if a user is signed in, and ` Activity.RESULT_CANCELLED ` if
204- sign in failed. No further information on failure is provided as it is not
202+ The authentication flow only provides three response codes:
203+ ` Activity.RESULT_OK ` if a user is signed in, ` Activity.RESULT_CANCELLED ` if
204+ sign in failed, and ` ResultCodes.RESULT_NO_NETWORK ` if sign in failed due to a lack of network connectivity.
205+ No further information on failure is provided as it is not
205206typically useful; the only recourse for most apps if sign in fails is to ask
206207the user to sign in again later, or proceed with an anonymous account if
207208supported.
208209
209210``` java
210211protected void onActivityResult(int requestCode, int resultCode, Intent data) {
211- super . onActivityResult(requestCode, resultCode, data);
212- if (requestCode == RC_SIGN_IN ) {
213- if (resultCode == RESULT_OK ) {
214- // user is signed in!
215- startActivity(new Intent (this , WelcomeBackActivity . class));
216- finish();
217- } else {
218- // user is not signed in. Maybe just wait for the user to press
219- // "sign in" again, or show a message
220- }
221- }
212+ super . onActivityResult(requestCode, resultCode, data);
213+ if (resultCode == RESULT_OK ) {
214+ // user is signed in!
215+ startActivity(new Intent (this , WelcomeBackActivity . class));
216+ finish();
217+ return ;
218+ }
219+
220+ // Sign in cancelled
221+ if (resultCode == RESULT_CANCELED ) {
222+ showSnackbar(R . string. sign_in_cancelled);
223+ return ;
224+ }
225+
226+ // No network
227+ if (resultCode == ResultCodes . RESULT_NO_NETWORK ) {
228+ showSnackbar(R . string. no_internet_connection);
229+ return ;
230+ }
231+
232+ // User is not signed in. Maybe just wait for the user to press
233+ // "sign in" again, or show a message.
222234 }
223235```
224236
0 commit comments