roiberg roiberg - 1 year ago 105
Android Question

Asking for READ_SMS asks for "send and view SMS messages"

My app needs to use a "READ_SMS" permission only.
My problem is that on Android 6.0 When I need to use the new permission system it asks a "send and view SMS messages" from the user.

This is my code:

ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_SMS}, READ_SMS_PERMISION_REQ);

What is going on?

Answer Source

What is going on?

It is working as expected.

While we request permissions via requestPermissions(), the user accepts or denies permission groups. So, if your array had READ_SMS and SEND_SMS, despite having two permissions, the user would only have to accept one thing in the runtime permission dialog. Or, if you only had READ_SMS here (and the user grants the permission), but then later called checkSelfPermission() for SEND_SMS, you would be told that you have it, as the user granted the whole SMS permission group.

The downside is that the permission groups often cover read and write permissions, so even if you only ask for read, the user is told that you might write.

My guess is that the objective was to keep the granularity of accept/deny decisions down. The fact that requestPermissions() takes permissions, not groups, means that Google has the right to change its mind in future versions of Android, if this read vs. write issue becomes a problem for users or developers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download