I want to implement an NotificationListenerService to get access to all notifications that are posted to the notification bar.
I understand that I need to enable access to the Notifications in the Settings with this call:
startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
Is there a way to check if the user activated Notification access for my app?
Built-in voice Notifications for Android phonesTalkback will read out loud notifications as they arrive along with everything on your screen (not just notifications). However, this changes the way you interact with your phone, which might be a drawback if you are looking for app to only read out loud notifications.
I managed to find a slight hack to solve this. If you check the source of Settings.Secure
, you will see that ENABLED_NOTIFICATION_LISTENERS
is annotated with @hide
. I don't know if this is intentional or not. On a related topic, CommonsWare does mention in another answer that there is a bug preventing the starting of this setting so I guess is unintentional.
Anyway, to work around this, all I did was to fetch the current list of enabled notification listeners using the string value of ENABLED_NOTIFICATION_LISTENERS
:
String enabledListeners = Settings.Secure.getString(context.getContentResolver(),
"enabled_notification_listeners");
Then you just have to check if your service is in the list.
I did not test this on all API >= 18 yet but it is working on Android 4.4.2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With