JavaChipMocha JavaChipMocha - 4 months ago 25
Android Question

requestPermissions() is not calling onRequestPermissionsResult()

Any reason why onRequestPermissionsResult() won't be called?

Say in Activity A, I have requestPermission(Permission A, Permission A code).
In Activity B, I have onRequestPermissionsResult which has an

if (requestCode == PermissionA.requestCode)


Shouldn't this work without any issues? Or am I doing something wrong.

I checked by putting debug logs and it calls requestPermission() and shows the disclosure UI (asking to accept and deny permission) but nothing happens after I press Accept, even though it should resume whatever I was trying to do.

Answer

Shouldn't this work without any issues?

No. If you call requestPermissions() for Activity A, that will trigger onRequestPermissionsResult() in Activity A, not Activity B.

Comments