Does android.permission.BINDNOTIFICATIONLISTENER_SERVICE permission allows the app to…
- User
Does android.permission.BIND_NOTIFICATION_LISTENER_SERVICE permission allows the app to read contents of the notification? I only need to know the fact that notification is currently shown.
- Assistant
The permission
android.permission.BIND_NOTIFICATION_LISTENER_SERVICEis required for an app to bind a Notification Listener Service. This type of service allows an app to receive callbacks about notifications as they are posted, updated, and removed.Does this permission allow reading the contents of the notification?
- Yes. When your app has a Notification Listener Service bound with this permission, it can access full details of notifications, including:
- The notification's title, text, and other content.
- The package name of the app that posted the notification.
- Actions and extras attached to the notification.
In other words, the app can read much more than just a fact that a notification exists — it can read the contents and payload of that notification.
If you only want to know whether a notification is currently shown
- Unfortunately, there is no simpler or more privacy-friendly permission that only grants knowledge of whether notifications exist.
- To receive any form of notification status from other apps, you need to use a Notification Listener Service, which inherently grants access to the full notification details.
- You cannot restrict your app (via a permission or API) to only know "a notification is currently shown" without also having the ability to read its contents.
Summary
Question Answer Does BIND_NOTIFICATION_LISTENER_SERVICEallow reading notification contents?Yes Is it possible to only detect the presence of notifications without reading them? No (using public Android APIs)
Note: Because of privacy concerns, the user must explicitly enable the notification listener service for your app in system settings (under "Notification access"), so users have control over granting this capability.
If you want to simply detect your own app’s notifications, you can track that internally without this permission. But for all other apps’ notifications,
BIND_NOTIFICATION_LISTENER_SERVICEwith a NotificationListenerService is required and allows reading contents. - Yes. When your app has a Notification Listener Service bound with this permission, it can access full details of notifications, including:
- User
My Android app uses media projection to capture screen content. Can I make it so that SMS and other notifications are not captured (excluded from capture)?
- Assistant
When you use MediaProjection API to capture the screen, you are essentially recording everything that appears on the device screen, including system UI elements such as:
- SMS notifications ("heads-up" banners or lock screen notifications)
- Other app notifications
- Navigation bars, status bars, etc.
Can you exclude SMS or other notifications from being captured?
No, there is no built-in or standard Android API to selectively exclude system notifications from MediaProjection screen capture.
The reasons:
-
MediaProjection captures the entire screen content as rendered, without any way to filter or mask specific areas or UI elements from the image stream.
-
The system does not provide granular controls or callbacks to suppress notifications only during projection.
-
Notification appearance is handled separately by the system UI and is composited into the frame that MediaProjection grabs — so any notification shown while projection is active will be included.
Possible workarounds (with caveats):
-
Suppress notifications while capturing:
-
You could try to temporarily disable or silence notifications during capture by toggling "Do Not Disturb" mode (
NotificationManager#setInterruptionFilter(...)with appropriate permissions). -
Or programmatically cancel notifications from apps your app controls.
-
But you cannot control or prevent notifications from all apps (system, SMS, third-party) in a reliable way without user action.
-
-
Request user cooperation:
-
Ask the user to enable Do Not Disturb before starting screen capture.
-
Encourage users to disable notifications or enable "Silent" notifications temporarily.
-
-
Use secure flags to block screenshots & capture of sensitive UI:
-
For your own app's UI, you can use
WindowManager.LayoutParams.FLAG_SECUREto prevent screen captures and recordings. -
However, this does not apply to notifications or other apps' UI, and does not help when you want to capture but exclude notifications.
-
Summary
Can MediaProjection exclude notifications from capture? No Is there an official API or flag to filter notifications from MediaProjection? No Practical ways to avoid capturing notifications Use Do Not Disturb or ask users to disable them manually
Additional note:
Some devices or custom OS versions might provide OEM-specific features or privacy settings that suppress notifications during casting or capturing, but there is no universal Android API for that.
Bottom line: If notifications appear on screen, MediaProjection will capture them as part of the screen contents. You cannot selectively exclude them programmatically. Your best bet is minimizing notifications via Do Not Disturb or user action.
- User
Which permission do I need for NotificationManager#setInterruptionFilter(...)? Also, can I programmatically detect that "do not disturb" mode is enabled?
- Assistant
Great questions! Here's the detailed info:
1. Permission for
NotificationManager#setInterruptionFilter(...)To call:
NotificationManager.setInterruptionFilter(int interruptionFilter)and programmatically change the device's Do Not Disturb (DND) mode, your app must hold the following permission:
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />- This is a normal permission, but users must explicitly grant your app Notification Policy Access in system settings.
- Your app cannot change DND mode without user consent.
- To prompt the user to grant access, you can send them to the settings screen via:
Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS); startActivity(intent);
2. Detecting if Do Not Disturb mode is enabled
You can query current interruption filter via:
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); int filter = notificationManager.getCurrentInterruptionFilter();The returned
filterindicates the current DND state:NotificationManager.INTERRUPTION_FILTER_ALL
→ No DND, all notifications allowed.NotificationManager.INTERRUPTION_FILTER_PRIORITY
→ Priority interruptions only.NotificationManager.INTERRUPTION_FILTER_NONE
→ No interruptions (DND fully on).NotificationManager.INTERRUPTION_FILTER_ALARMS
→ Alarms only.NotificationManager.INTERRUPTION_FILTER_UNKNOWN
→ Unknown state.
Example:
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int currentFilter = notificationManager.getCurrentInterruptionFilter(); boolean isDoNotDisturbOn = currentFilter != NotificationManager.INTERRUPTION_FILTER_ALL;If
isDoNotDisturbOnistrue, this means some form of DND is active.
Summary
Feature Requirement / Notes Permission to call setInterruptionFilter()android.permission.ACCESS_NOTIFICATION_POLICYUser action needed User must grant Notification Policy Access in settings Detect DND enabled Use getCurrentInterruptionFilter()Interruption filters Provide state info on DND modes
Let me know if you'd like example code snippets or details on how to request the permission from users!