I want to get permission to read SMS in my application. 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 did not receive a dialog to confirm the request for permission. For other permissions (e.g. WRITE_STORAGE, READ_CONTACTS) I got this dialog. Do you know how to fix this?
The method onRequestPermissionsResultgives me that permission is not granted. But it works without a confirmation dialog.
source
share