Android Question How to handle muliple requests to the same permission from one Activity?

corwin42

Expert
Licensed User
Longtime User
I have in one Activity the need to request the same permission (PERMISSION_READ_EXTERNAL_STORAGE) from different situations.

In the API of the runtimepermissions therefore you can provide a different integer value for both situations. In the permission result event this code is provided, too, so that you can decide for which situation the permission was granted.

Unfortunately in B4A we don't have this additional code and we cannot simply decide from where rp.CheckAndRequest(<Permission>) was called.

What is the correct way to handle this situation?
The only solution I can think of are global flags that I can set if I request a permission, check them in the result and clear them again. Is this the way to go in B4A?
 

corwin42

Expert
Licensed User
Longtime User
You will need to use a global variable to distinguish between the two cases.

Ok, I have implemented it this way. Works well.
 
Upvote 0
Top