android / android/camera-samples

How should I requestPermissions again?

Open
#340 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
5.5k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Hello, I am facing issues regarding permissions. For instance, right now if the user declines to provide permission you are showing a Toast. I tried to request permissions again, but I received a crash(java.lang.StackOverflowError: stack size 8192KB). Can you suggest the correct approach on how to ask for permissions again?

` override fun onRequestPermissionsResult(
requestCode: Int, permissions: Array, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == PERMISSIONS_REQUEST_CODE) {
if (PackageManager.PERMISSION_GRANTED == grantResults.firstOrNull()) {
// Take the user to the success fragment when permission is granted
Toast.makeText(context, "Permission request granted", Toast.LENGTH_LONG).show()
Navigation.findNavController(requireActivity(), R.id.fragment_container).navigate(
PermissionsFragmentDirections.actionPermissionsToCamera())
} else {
requestPermissions(PERMISSIONS_REQUIRED, PERMISSIONS_REQUEST_CODE)
Toast.makeText(context, "Permission request denied", Toast.LENGTH_LONG).show()
}
}
}
`

Contributor guide

Open the contributing guide

Research direction

Start at the onRequestPermissionsResult callback and its requestPermissions call shown in the issue, then read the Android runtime-permission callback behavior. Reproduce the denial path and trace the StackOverflowError. Done means the retry behavior is clearly established and the denial path no longer recurses into a stack overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.