Condividi tramite


NotificationManager Class

Definition

Class to notify the user of events that happen.

[Android.Runtime.Register("android/app/NotificationManager", DoNotGenerateAcw=true)]
public class NotificationManager : Java.Lang.Object
[<Android.Runtime.Register("android/app/NotificationManager", DoNotGenerateAcw=true)>]
type NotificationManager = class
    inherit Object
Inheritance
NotificationManager
Attributes

Remarks

Class to notify the user of events that happen. This is how you tell the user that something has happened in the background.

Notifications can take different forms: <ul> <li>A persistent icon that goes in the status bar and is accessible through the launcher, (when the user selects it, a designated Intent can be launched),</li> <li>Turning on or flashing LEDs on the device, or</li> <li>Alerting the user by flashing the backlight, playing a sound, or vibrating.</li> </ul>

Each of the notify methods takes an int id parameter and optionally a String tag parameter, which may be null. These parameters are used to form a pair (tag, id), or (null, id) if tag is unspecified. This pair identifies this notification from your app to the system, so that pair should be unique within your app. If you call one of the notify methods with a (tag, id) pair that is currently active and a new set of notification parameters, it will be updated. For example, if you pass a new status bar icon, the old icon in the status bar will be replaced with the new one. This is also the same tag and id you pass to the #cancel(int) or #cancel(String, int) method to clear this notification.

<div class="special reference"> <h3>Developer Guides</h3>

For a guide to creating notifications, read the Status Bar Notifications developer guide.

</div>

Java documentation for android.app.NotificationManager.

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.

Constructors

NotificationManager(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

ActionAppBlockStateChanged

Intent that is broadcast when an application is blocked or unblocked.

ActionAutomaticZenRule

Activity Action: Launch an Automatic Zen Rule configuration screen

ActionAutomaticZenRuleStatusChanged

Intent that is broadcast when the status of an AutomaticZenRule has changed.

ActionInterruptionFilterChanged

Intent that is broadcast when the state of getCurrentInterruptionFilter() changes.

ActionNotificationChannelBlockStateChanged

Intent that is broadcast when a NotificationChannel is blocked (when NotificationChannel#getImportance() is #IMPORTANCE_NONE) or unblocked (when NotificationChannel#getImportance() is anything other than #IMPORTANCE_NONE).

ActionNotificationChannelGroupBlockStateChanged

Intent that is broadcast when a NotificationChannelGroup is NotificationChannelGroup#isBlocked() blocked or unblocked.

ActionNotificationPolicyAccessGrantedChanged

Intent that is broadcast when the state of #isNotificationPolicyAccessGranted() changes.

ActionNotificationPolicyChanged

Intent that is broadcast when the state of getNotificationPolicy() changes.

AutomaticRuleStatusDisabled
Obsolete.

Constant value for #EXTRA_AUTOMATIC_ZEN_RULE_STATUS - the given rule currently exists but is disabled.

AutomaticRuleStatusEnabled
Obsolete.

Constant value for #EXTRA_AUTOMATIC_ZEN_RULE_STATUS - the given rule currently exists and is enabled.

AutomaticRuleStatusRemoved
Obsolete.

Constant value for #EXTRA_AUTOMATIC_ZEN_RULE_STATUS - the given rule has been deleted.

AutomaticRuleStatusUnknown
Obsolete.

Constant value for #EXTRA_AUTOMATIC_ZEN_RULE_STATUS - the current status of the rule is unknown at your target sdk version, and you should continue to provide state changes via #setAutomaticZenRuleState(String, Condition).

BubblePreferenceAll
Obsolete.

Indicates that all bubbles are allowed from the app.

BubblePreferenceNone
Obsolete.

Indicates that the no bubbles are allowed from the app.

BubblePreferenceSelected
Obsolete.

Indicates that only notifications selected by the user will appear as bubbles.

ExtraAutomaticRuleId

Used as an optional string extra on #ACTION_AUTOMATIC_ZEN_RULE intents.

ExtraAutomaticZenRuleId

String extra for #ACTION_AUTOMATIC_ZEN_RULE_STATUS_CHANGED containing the id of the AutomaticZenRule (see #addAutomaticZenRule(AutomaticZenRule)) that has changed.

ExtraAutomaticZenRuleStatus

Integer extra for #ACTION_AUTOMATIC_ZEN_RULE_STATUS_CHANGED containing the state of the AutomaticZenRule.

ExtraBlockedState

Extra for #ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED or #ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED containing the new blocked state as a boolean.

ExtraNotificationChannelGroupId

Extra for #ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED containing the id of the NotificationChannelGroup which has a new blocked state.

ExtraNotificationChannelId

Extra for #ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED containing the id of the NotificationChannel which has a new blocked state.

ImportanceDefault
Obsolete.

Default notification importance: shows everywhere, makes noise, but does not visually intrude.

ImportanceHigh
Obsolete.

Higher notification importance: shows everywhere, makes noise and peeks.

ImportanceLow
Obsolete.

Low notification importance: Shows in the shade, and potentially in the status bar (see #shouldHideSilentStatusBarIcons()), but is not audibly intrusive.

ImportanceMax
Obsolete.

Unused.

ImportanceMin
Obsolete.

Min notification importance: only shows in the shade, below the fold.

ImportanceNone
Obsolete.

A notification with no importance: does not show in the shade.

ImportanceUnspecified
Obsolete.

Value signifying that the user has not expressed an importance.

MetaDataAutomaticRuleType

A required meta-data tag for activities that handle #ACTION_AUTOMATIC_ZEN_RULE.

MetaDataRuleInstanceLimit

An optional meta-data tag for activities that handle #ACTION_AUTOMATIC_ZEN_RULE.

Properties

AutomaticZenRules

Returns AutomaticZenRules owned by the caller.

BubblePreference

Gets the bubble preference for the app.

Class

Returns the runtime class of this Object.

(Inherited from Object)
ConsolidatedNotificationPolicy

Returns the currently applied notification policy.

CurrentInterruptionFilter

Gets the current notification interruption filter.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
Importance

Returns the user specified importance for notifications from the calling package.

IsNotificationPolicyAccessGranted

Checks the ability to modify notification do not disturb policy for the calling package.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
NotificationChannelGroups

Returns all notification channel groups belonging to the calling app.

NotificationChannels

Returns all notification channels belonging to the calling package.

NotificationDelegate

Returns the #setNotificationDelegate(String) delegate that can post notifications on your behalf, if there currently is one. -or- Allows a package to post notifications on your behalf using #notifyAsPackage(String, String, int, Notification).

NotificationPolicy

Gets the current user-specified default notification policy. -or- Sets the current notification policy.

PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddAutomaticZenRule(AutomaticZenRule)

Creates the given zen rule.

AreBubblesAllowed()

Gets whether all notifications posted by this app can appear outside of the notification shade, floating over other apps' content.

AreBubblesEnabled()

Returns whether bubbles are enabled at the feature level for the current user.

AreNotificationsEnabled()

Returns whether notifications from the calling package are enabled.

AreNotificationsPaused()

Returns whether notifications from this package are temporarily hidden.

Cancel(Int32)

Cancels a previously posted notification.

Cancel(String, Int32)

Cancels a previously posted notification.

CancelAll()

Cancel all previously shown notifications.

CancelAsPackage(String, String, Int32)

Cancels a previously posted notification.

CanNotifyAsPackage(String)

Returns whether you are allowed to post notifications on behalf of a given package, with #notifyAsPackage(String, String, int, Notification).

CanUseFullScreenIntent()

Returns whether the calling app can send fullscreen intents.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CreateNotificationChannel(NotificationChannel)

Creates a notification channel that notifications can be posted to.

CreateNotificationChannelGroup(NotificationChannelGroup)

Creates a group container for NotificationChannel objects.

CreateNotificationChannelGroups(IList<NotificationChannelGroup>)

Creates multiple notification channel groups.

CreateNotificationChannels(IList<NotificationChannel>)

Creates multiple notification channels that different notifications can be posted to.

DeleteNotificationChannel(String)

Deletes the given notification channel.

DeleteNotificationChannelGroup(String)

Deletes the given notification channel group, and all notification channels that belong to it.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FromContext(Context)
GetActiveNotifications()

Recover a list of active notifications: ones that have been posted by the calling app that have not yet been dismissed by the user or #cancel(String, int)ed by the app.

GetAutomaticZenRule(String)

Returns the AutomaticZenRule with the given id, if it exists and the caller has access.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetNotificationChannel(String, String)

Returns the notification channel settings for a given channel and ShortcutInfo#getId() conversation id.

GetNotificationChannel(String)

Returns the notification channel settings for a given channel id.

GetNotificationChannelGroup(String)

Returns the notification channel group settings for a given channel group id.

IsNotificationListenerAccessGranted(ComponentName)

Checks whether the user has approved a given android.service.notification.NotificationListenerService.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
MatchesCallFilter(Uri)

Returns whether a call from the provided URI is permitted to notify the user.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
Notify(Int32, Notification)

Post a notification to be shown in the status bar.

Notify(String, Int32, Notification)

Posts a notification to be shown in the status bar.

NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
NotifyAsPackage(String, String, Int32, Notification)

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

RemoveAutomaticZenRule(String)

Deletes the automatic zen rule with the given id.

SetAutomaticZenRuleState(String, Condition)

Informs the notification manager that the state of an AutomaticZenRule has changed.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetInterruptionFilter(InterruptionFilter)

Sets the current notification interruption filter.

ShouldHideSilentStatusBarIcons()

Returns whether the user wants silent notifications (see #IMPORTANCE_LOW to appear in the status bar.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
UpdateAutomaticZenRule(String, AutomaticZenRule)

Updates the given zen rule.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to