Last active
September 10, 2020 02:43
-
-
Save coolya/305062e405ba8fb058fc to your computer and use it in GitHub Desktop.
How to check if you app has permission to get notification service listener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean hasNotificationAccess() | |
{ | |
ContentResolver contentResolver = this.getContentResolver(); | |
String enabledNotificationListeners = Settings.Secure.getString(contentResolver, "enabled_notification_listeners"); | |
String packageName = this.getPackageName(); | |
// check to see if the enabledNotificationListeners String contains our package name | |
return !(enabledNotificationListeners == null || !enabledNotificationListeners.contains(packageName)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment