Home > Software engineering >  Where do I find the request codes for permissions for android?
Where do I find the request codes for permissions for android?

Time:09-02

I am looking for the send sms request code. I have the 111 code, but that requests permission to read and send text messages. I do not see a constant in the help box. Is there a permission to send sms only, and is there a webpage that will show me all the different requests codes or do you just gotta guess?

So I threw in random numbers in the request code, and it still asked the permission, so does anyone know what this code is for or does, and how can I get it to send sms only and not read?

 //what I am currently using to request the permission, just want to send sms, not read/send 
 //which this requests

 ActivityCompat.requestPermissions(this, arrayOf(SEND_SMS), 111 )

CodePudding user response:

The permissions requests on android can be done only for a permission group and not for the single permissions. The permissions to send and receive sms belong to the same permission group and you cannot be granted only for an individual permission.

The 111 request code instead can be a random number that you choose and it does not affect the permission request behaviour. This request code is returned in the callback onRequestPermissionsResult and you can compare this code to identify the request.

  • Related