-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add startActivityForResult explanation #435
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
Conversation
@@ -91,14 +91,15 @@ Twitter app as reported by the [Twitter application manager](https://apps.twitte | |||
</resources> | |||
``` | |||
|
|||
In addition, if are using Smart Lock or require a user's email, you must enable the | |||
In addition, if you are using Smart Lock or require a user's email, you must enable the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops
@@ -147,6 +148,14 @@ startActivityForResult( | |||
RC_SIGN_IN); | |||
``` | |||
|
|||
<a href="https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)">`startActivityForResult`</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be in HTML because of the parentheses in the link.
The number you chose is arbitrary as long as it doesn't conflict with other | ||
`startActivityForResult` requests you might be making. In [response codes](#response-codes), | ||
you will see how we can use `RC_SIGN_IN` to differentiate between multiple `startActivityForResult` requests. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really meaty, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that discusses the mechanics of startActivityForResult a little too much, how about something like this:
To kick off the FirebaseUI sign in flow, call startActivityForResult(...)
on the sign in Intent you built. The second parameter (RC_SIGN_IN
) is a request code you define to identify the request when the result is returned to your app in onActivityResult(...)
. See the response codes section below for more details on receiving the results of the sign in flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I went a bit too far... 😄
if (resultCode == RESULT_CANCELED) { | ||
showSnackbar(R.string.sign_in_cancelled); | ||
return; | ||
if (requestCode == RC_SIGN_IN) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a small comment here something like // RC_SIGN_IN is the request code you passed into startActivityForResult when starting the sign in flow
@@ -147,6 +148,14 @@ startActivityForResult( | |||
RC_SIGN_IN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a line above this code snippet to be super clear:
// Choose an arbitrary request code value
private static final int RC_SIGN_IN = 123;
// ...
startActivityForResult(
Thanks for getting on this so fast! |
Done! |
#434