0

Where can I find "list of permission codes" in which I can chose the permission code? For example what should be the value of permissionCode for recording audio permission request:

ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.RECORD_AUDIO},
                        permissionCode);

2 Answers2

1

You can choose any non-negative number, however, values greater than 65535 may not work in some cases (see Android: what to choose for requestcode values? for more info). Underneath, the same mechanism as in startActivityForResult() is used there.

koral
  • 2,513
  • 1
  • 32
  • 41
0

You can choose a number that you want. Then when overriding onRequestPermissionsResult you can check if the user agreed to the permission or not by the permissionCode which you entered.

You can read more about that here.

Phil90
  • 138
  • 1
  • 16
  • I have already read instructions on that page but trying to grasp exactly what the permissionCode variable stands for. – hasanayture Jun 18 '17 at 16:36
  • Okay I'll try to explain it a bit more: It could be possible that you request multiple permissions, e.g. RECORD_AUDIO and INTERNET. After requesting a permission the method onRequestPermissionsResult gets called. To know if this method got called for the RECORD_AUDIO permission or the INTERNET permission you have the permissionCode. When you request the audio permission with the permissionCode 1234 you can check in onRequestPermissionResult if the parameter requestCode is 1234. If so you know that the method call comes from the audio permission and not from the internet permission. – Phil90 Jun 18 '17 at 16:43