-
Notifications
You must be signed in to change notification settings - Fork 118
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
Fix crash on autocomplete error #734
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Thanks for opening this PR! Before we merge it, could you please
Thanks again and let me know if you have any questions! |
Hi @arnaud33200 ! Did you have the chance to take a look at the message above? We would need you to sign the CLA, and also to rewrite the commit title/message to follow the conventional commit guidelines. Let us know if you have any further questions, thanks! |
val status = Autocomplete.getStatusFromIntent(result.data) | ||
binding.response.text = "Error: ${status.statusMessage}" |
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 has a potential NPE. How about the following change?
val status = Autocomplete.getStatusFromIntent(result.data) | |
binding.response.text = "Error: ${status.statusMessage}" | |
binding.response.text = result.data?.let { intent -> | |
getString( | |
R.string.error_message, | |
Autocomplete.getStatusFromIntent(intent).statusMessage | |
) | |
} ?: getString(R.string.error_unknown) |
And add the following to demo-kotlin/app/src/main/res/values/strings.xml
<!-- message to show for errors received from the API. -->
<string name="error_message" translatable="false">Error: %1$s</string>
<!-- message to show if the error status is unavailable. -->
<string name="error_unknown" translatable="false">Unexpected error</string>
fix a crash when there is an error result for
autocompleteLauncher
Fixes #733 🦕