Skip to content

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

Merged
merged 4 commits into from
Dec 2, 2016
Merged

Add startActivityForResult explanation #435

merged 4 commits into from
Dec 2, 2016

Conversation

SUPERCILEX
Copy link
Collaborator

@SUPERCILEX SUPERCILEX commented Dec 2, 2016

@@ -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
Copy link
Collaborator Author

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>
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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?

Copy link
Contributor

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.

Copy link
Collaborator Author

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) {
Copy link
Contributor

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);
Copy link
Contributor

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(

@samtstern
Copy link
Contributor

Thanks for getting on this so fast!

@SUPERCILEX
Copy link
Collaborator Author

Done!

@samtstern samtstern merged commit 3c7a32c into firebase:master Dec 2, 2016
@SUPERCILEX SUPERCILEX deleted the patch-1 branch December 2, 2016 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants