Skip to content

Instantly share code, notes, and snippets.

@xingrz
Created March 23, 2014 11:28
Show Gist options
  • Save xingrz/9721883 to your computer and use it in GitHub Desktop.
Save xingrz/9721883 to your computer and use it in GitHub Desktop.
String enabledNotificationListeners = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
// check to see if the enabledNotificationListeners String contains our package name
if (enabledNotificationListeners == null || !enabledNotificationListeners.contains(context.getPackageName())) {
// in this situation we know that the user has not granted the app the Notification access permission
throw new Exception();
} else {
doSomethingThatRequiresNotificationAccessPermission();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment