I am trying to request STORAGE Permission from the user at runtime after clicking a certain button. But somehow, this code (which is contained within a fragment's class) is not working at all no matter what I try.
binding.button.setOnClickListener {
requestPermissions(this.requireActivity(), "android.permission.WRITE_EXTERNAL_STORAGE", 392)
}
This piece of code isn't working either for both write and read permissions :
binding.button.setOnClickListener {
ActivityCompat.requestPermissions(this.requireActivity(), "android.permission.WRITE_EXTERNAL_STORAGE", 392)
}
No dialogue appears no matter what.
NOTE: I am testing on a physical device running on API 29. NOTE2: I added the permission both WRITE and READ permissions to the manifest. NOTE3: Performing any IO task crashes my app.
I looked up all over the internet but I still don't understand why it's not working.