Udostępnij za pośrednictwem


DevicePolicyManager.SetPermittedCrossProfileNotificationListeners Method

Definition

Called by a profile owner of a managed profile to set the packages that are allowed to use a android.service.notification.NotificationListenerService in the primary user to see notifications from the managed profile.

[Android.Runtime.Register("setPermittedCrossProfileNotificationListeners", "(Landroid/content/ComponentName;Ljava/util/List;)Z", "GetSetPermittedCrossProfileNotificationListeners_Landroid_content_ComponentName_Ljava_util_List_Handler", ApiSince=26)]
public virtual bool SetPermittedCrossProfileNotificationListeners (Android.Content.ComponentName admin, System.Collections.Generic.IList<string>? packageList);
[<Android.Runtime.Register("setPermittedCrossProfileNotificationListeners", "(Landroid/content/ComponentName;Ljava/util/List;)Z", "GetSetPermittedCrossProfileNotificationListeners_Landroid_content_ComponentName_Ljava_util_List_Handler", ApiSince=26)>]
abstract member SetPermittedCrossProfileNotificationListeners : Android.Content.ComponentName * System.Collections.Generic.IList<string> -> bool
override this.SetPermittedCrossProfileNotificationListeners : Android.Content.ComponentName * System.Collections.Generic.IList<string> -> bool

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with.

packageList
IList<String>

List of package names to allowlist

Returns

true if setting the restriction succeeded. It will fail if called outside a managed profile

Attributes

Remarks

Called by a profile owner of a managed profile to set the packages that are allowed to use a android.service.notification.NotificationListenerService in the primary user to see notifications from the managed profile. By default all packages are permitted by this policy. When zero or more packages have been added, notification listeners installed on the primary user that are not in the list and are not part of the system won't receive events for managed profile notifications.

Calling with a null value for the list disables the restriction so that all notification listener services be used. Calling with an empty list disables all but the system's own notification listeners. System notification listener services are always available to the user.

If a device or profile owner want to stop notification listeners in their user from seeing that user's notifications they should prevent that service from running instead (e.g. via #setApplicationHidden(ComponentName, String, boolean))

Java documentation for android.app.admin.DevicePolicyManager.setPermittedCrossProfileNotificationListeners(android.content.ComponentName, java.util.List<java.lang.String>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to