Using the new ActivityResults API for handling runtime permission requests #985
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in (mentions #982), the requestPermissions() and onRequestPermissionsResult() APIs are deprecated with androidx fragment version 1.3.0
The new approach is to use ActivityResults API and
RequestPermission
contract for requesting single permission at a time orRequestMultiplePermissions
contract for requesting multiple permission at a time for handling runtime permission requests.This article also mentions this quite well.
For the microphone request purpose, we have a single permission request to process so I am using
RequestPermission
contract here.I see multiple locations where we are using requestPermissions() in the
app
and other parts of the project. This PR is specific to thefeature/voicecommand
project.I would love to implement this upgrade over the entire project in future. Let me know your thoughts.