Android 6.0 Permissions. Read SMS

Vanya Sakharovskiy picture Vanya Sakharovskiy · Jan 19, 2016 · Viewed 11.3k times · Source

I want to get the permission to read SMS in my App. This is my code:

String permission = Manifest.permission.READ_SMS;
if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED){
    permissionList.add(permission);

    if (!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)){
        requestPermissions(new String[]{permission}), SMS_PERMISSION);
    }
}

I didn't get dialog to confirm the permission request. For other permissions (like WRITE_STORAGE, READ_CONTACTS) I got this dialog. Do you know how to fix it?

Method onRequestPermissionsResult gives to me that permission isn't granted. But it works, without the confirmation dialog.

Answer

Vanya Sakharovskiy picture Vanya Sakharovskiy · Oct 26, 2016

I need the <uses-permission-sdk-23/> for confirm dialog.