Skip to content
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

Android - Changed ActivityResult requestCode to be a value different than 0 #641

Conversation

KrasimirGatevMentorMate
Copy link
Contributor

Android - Changed ActivityResult requestCode to be a value different than 0

Possible fix for #600

Description

Changed ActivityResult requestCode to be a value different than 0, as this can cause some unforeseen issues in Andorid and is not a good practice in general.

Changed ActivityResult requestCode to be a value different than 0, as this can cause some unforeseen issues.
@kadikraman
Copy link
Contributor

Thanks for the PR! Could you explain why passing in 0 as the request code is not a good practice? I couldn't find anything specific when Googling this.

@KrasimirGatevMentorMate
Copy link
Contributor Author

Hi, thank you for the answer. The requestCode value is used so that for a given Activity, in onActivityResult() can distinguish between the results of different requests that were started with startActivityForResult(). The value should be as unique as possible so as to avoid colissions. Althout there is only one startActivityForResult() called in the library code currently, activities using different libraries such as QR code scanners etc. can also call their own startActivityForResult() and the codes could get mixed especially when using 0 as a value.

This change is an attemp at handling issues #600 which is experienced by many users including in our project in Production. This is a very hard to reproduce issues, but leads to NPE crashes, which have high impact for users, so I would be grateful if your team could take a more closer look at it. Although it is a bit of a "long shot" in any case in my oppinion, having requestCode be a concrete value will be a net improvement to the onActivityResult() function. Thank you for your time and hard work.

@kadikraman kadikraman merged commit 51cfc6e into FormidableLabs:main Jun 27, 2021
@kadikraman
Copy link
Contributor

Released in v6.4.0 🎉

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