Skip to content Skip to sidebar Skip to footer

How To Request Do Not Disturb Permission On Samsung S5 (sm-g800h)?

This is the usual way to request DND permission: Intent intent = new Intent(); intent.setAction('android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS'); startActivityForResult(inte

Solution 1:

This might not be a Samsung related issue. According to the official docs, ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS is available only on API 23+ (Marshmallow). Does the S5 you're testing on have Android 6 Marshmallow running? If not, that's your problem.

EDIT: Since this Activity may not be present on each device even if they are on Android 6, you'll need to handle the case where the intent can't be resolved. So something like this might be what you want:

PackageManagerpackageManager= getActivity().getPackageManager();

Intentintent=newIntent();
intent.setAction("android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS");

if (intent.resolveActivity(packageManager) != null) {
    startActivityForResult(intent, NOTIFICATION_REQUEST_CODE);
} else {
    Log.d(TAG, "No Intent available to handle action");
}

Post a Comment for "How To Request Do Not Disturb Permission On Samsung S5 (sm-g800h)?"