Accessing Android NotificationListenerService Settings
Additional to CommonsWare answer here is how to check if you have that permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (!NotificationManagerCompat.getEnabledListenerPackages(this).contains(getPackageName())) { //ask for permission
Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
startActivity(intent);
}
}
Am I missing something?
Well, in your last one, you are conflating an action string with a class name. The "manual" approach would be:
Intent intent=new Intent("android.settings.NOTIFICATION_LISTENER_SETTINGS");
In terms of why Android Studio is not finding Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS
, that I can't say.
UPDATE
Based on the discussion in the comments, Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS
is not in the Android SDK at present (marked with @hide
). Also, the manifest for the Settings app has a slightly different version of the action string:
Intent intent=new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");