Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? Thanks!

like image 696
roiberg Avatar asked Sep 20 '15 15:09

roiberg


People also ask

How do I give SMS permission?

In some versions of Android, this permission is turned on by default. In other versions, this permission is turned off by default. To set the app's permission on a device or emulator instance, choose Settings > Apps > SMS Messaging > Permissions, and turn on the SMS permission for the app.

What are SMS permissions?

Most of these are pretty self-explanatory---for instance, the SMS permission lets apps read and send text messages---but you'll see descriptions at the top of each page if you're not sure. Tap a permission and under Allowed, you'll see every app that you've approved to use that function.

How we can send and receive SMS in Android application?

Before starting your application, Android studio installer will display following window to select an option where you want to run your Android application. Now you can enter a desired mobile number and a text message to be sent on that number. Finally click on Send SMS button to send your SMS.


1 Answers

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.

like image 98
CommonsWare Avatar answered Sep 24 '22 21:09

CommonsWare