共用方式為


NotificationManager.NotifyAsPackage Method

Definition

Posts a notification as a specified package to be shown in the status bar.

[Android.Runtime.Register("notifyAsPackage", "(Ljava/lang/String;Ljava/lang/String;ILandroid/app/Notification;)V", "GetNotifyAsPackage_Ljava_lang_String_Ljava_lang_String_ILandroid_app_Notification_Handler", ApiSince=29)]
public virtual void NotifyAsPackage (string targetPackage, string? tag, int id, Android.App.Notification notification);
[<Android.Runtime.Register("notifyAsPackage", "(Ljava/lang/String;Ljava/lang/String;ILandroid/app/Notification;)V", "GetNotifyAsPackage_Ljava_lang_String_Ljava_lang_String_ILandroid_app_Notification_Handler", ApiSince=29)>]
abstract member NotifyAsPackage : string * string * int * Android.App.Notification -> unit
override this.NotifyAsPackage : string * string * int * Android.App.Notification -> unit

Parameters

targetPackage
String

The package to post the notification as. The package must have granted you access to post notifications on their behalf with #setNotificationDelegate(String).

tag
String

A string identifier for this notification. May be null.

id
Int32

An identifier for this notification. The pair (tag, id) must be unique within your application.

notification
Notification

A Notification object describing what to show the user. Must not be null.

Attributes

Remarks

Posts a notification as a specified package to be shown in the status bar. If a notification with the same tag and id has already been posted for that package and has not yet been canceled, it will be replaced by the updated information.

All android.service.notification.NotificationListenerService listener services will be granted Intent#FLAG_GRANT_READ_URI_PERMISSION access to any Uri uris provided on this notification or the NotificationChannel this notification is posted to using Context#grantUriPermission(String, Uri, int). Permission will be revoked when the notification is canceled, or you can revoke permissions with Context#revokeUriPermission(Uri, int).

Java documentation for android.app.NotificationManager.notifyAsPackage(java.lang.String, java.lang.String, int, android.app.Notification).

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