Redirect to Notification Access Settings

You can open the NotificationAccessSettingsActivity by using the following Intent, but I'm not sure about checking to see if they've already enabled your app.

startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));

Alternatively, for API 22+:

startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));

Many Thanks to @adneal and @Waboodoo. I am posting this for an complete answer

Check permission granted or not using this method

private boolean isNotificationServiceRunning() {
    ContentResolver contentResolver = getContentResolver();
    String enabledNotificationListeners =
            Settings.Secure.getString(contentResolver, "enabled_notification_listeners");
    String packageName = getPackageName();
    return enabledNotificationListeners != null && enabledNotificationListeners.contains(packageName);
}

Then show settings activity, if necessary

boolean isNotificationServiceRunning = isNotificationServiceRunning();
if(!isNotificationServiceRunning){
    startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
}

Tags:

Android