user3747512
user3747512

Reputation: 233

How to know if show notification is enabled or disabled, if yes how to access it on Android 4.4+ devices?

Is there a way to find if the "Show notification" for app is enabled or disabled? I have a requirement where I need to check and enable or disable notifications.

When you see the details of the any app, example in the link http://www.trickyways.com/wp-content/uploads/2014/05/show-notifications-disabled.png there is an option to disable notifications. Is there any function or method in Android with which I can extract this

I have seen articles that it can't be done for 4.0, wondering if there is any update for 4.4 and above

Upvotes: 0

Views: 94

Answers (1)

harsh201
harsh201

Reputation: 121

The solution is for API Level >= 18.

You can include NotificationListenerService in your project which allows you to listen to all the Notifications that are posted on the phone.

So whenever your application posts a new notification NotificationListenerService will get a callback. So, if you are posting a notification and NotificationListenerService is not getting a callback, it means user has blocked the notifications for your application.

Note that user needs to explicitly grant your application Notification Access Permission in order for your application to access the notifications.

Upvotes: 1

Related Questions