2

In Android 6.0/API23 and earlier, the following used to work:

String settingEnabled = android.provider.Settings.Secure.getString(this.getContentResolver(), "enabled_notification_listeners");

In Android 7.0 Nougat/API24 this seems to be no longer supported, because the code above returns null.

It actually was never mentioned here: https://developer.android.com/reference/android/provider/Settings.Secure.html

How do we check if our app has notification access in Android 7.0 Nougat API24?

Edit: It seems that actually that after you first gained the access in the settings, the code above returns the correct state. But not on the initial request after installation.

powerbar
  • 323
  • 3
  • 14

1 Answers1

7

Use this:

Set<String> packageNames = NotificationManagerCompat.getEnabledListenerPackages (context);
henrichg
  • 301
  • 2
  • 4
  • Wow! Thanks. Amazing how little documentation there is around this. There is no API in the Android SDK, but the support library provides the workaround haha. – Eric Cochran May 24 '17 at 00:14