NotificationListenerService.Ranking

public static class NotificationListenerService.Ranking
extends Object

java.lang.Object
   ↳ android.service.notification.NotificationListenerService.Ranking


Stores ranking related information on a currently active notification.

Ranking objects aren't automatically updated as notification events occur. Instead, ranking information has to be retrieved again via the current NotificationListenerService.RankingMap.

Summary

Constants

int USER_SENTIMENT_NEGATIVE

The user is likely to have a negative reaction to this notification.

int USER_SENTIMENT_NEUTRAL

It is not known how the user will react to this notification.

int USER_SENTIMENT_POSITIVE

The user is likely to have a positive reaction to this notification.

Public constructors

NotificationListenerService.Ranking()

Public methods

boolean canShowBadge()

Returns whether this notification can be displayed as a badge.

NotificationChannel getChannel()

Returns the notification channel this notification was posted to, which dictates notification behavior and presentation.

int getImportance()

Returns the importance of the notification, which dictates its modes of presentation, see: NotificationManager.IMPORTANCE_DEFAULT, etc.

CharSequence getImportanceExplanation()

If the importance has been overridden by user preference, then this will be non-null, and should be displayed to the user.

String getKey()

Returns the key of the notification this Ranking applies to.

String getOverrideGroupKey()

If the system has overridden the group key, then this will be non-null, and this key should be used to bundle notifications.

int getRank()

Returns the rank of the notification.

int getSuppressedVisualEffects()

Returns the type(s) of visual effects that should be suppressed for this notification.

int getUserSentiment()

Returns how the system thinks the user feels about notifications from the channel provided by getChannel().

boolean isAmbient()

Returns whether the notification is an ambient notification, that is a notification that doesn't require the user's immediate attention.

boolean isSuspended()

Returns whether the app that posted this notification is suspended, so this notification should be hidden.

boolean matchesInterruptionFilter()

Returns whether the notification matches the user's interruption filter.

Inherited methods

Constants

USER_SENTIMENT_NEGATIVE

added in API level 28
public static final int USER_SENTIMENT_NEGATIVE

The user is likely to have a negative reaction to this notification.

Constant Value: -1 (0xffffffff)

USER_SENTIMENT_NEUTRAL

added in API level 28
public static final int USER_SENTIMENT_NEUTRAL

It is not known how the user will react to this notification.

Constant Value: 0 (0x00000000)

USER_SENTIMENT_POSITIVE

added in API level 28
public static final int USER_SENTIMENT_POSITIVE

The user is likely to have a positive reaction to this notification.

Constant Value: 1 (0x00000001)

Public constructors

NotificationListenerService.Ranking

added in API level 21
public NotificationListenerService.Ranking ()

Public methods

canShowBadge

added in API level 26
public boolean canShowBadge ()

Returns whether this notification can be displayed as a badge.

Returns
boolean true if the notification can be displayed as a badge, false otherwise.

getChannel

added in API level 26
public NotificationChannel getChannel ()

Returns the notification channel this notification was posted to, which dictates notification behavior and presentation.

Returns
NotificationChannel

getImportance

added in API level 24
public int getImportance ()

Returns the importance of the notification, which dictates its modes of presentation, see: NotificationManager.IMPORTANCE_DEFAULT, etc.

Returns
int the importance of the notification

Value is IMPORTANCE_UNSPECIFIED, IMPORTANCE_NONE, IMPORTANCE_MIN, IMPORTANCE_LOW, IMPORTANCE_DEFAULT or IMPORTANCE_HIGH.

getImportanceExplanation

added in API level 24
public CharSequence getImportanceExplanation ()

If the importance has been overridden by user preference, then this will be non-null, and should be displayed to the user.

Returns
CharSequence the explanation for the importance, or null if it is the natural importance

getKey

added in API level 21
public String getKey ()

Returns the key of the notification this Ranking applies to.

Returns
String

getOverrideGroupKey

added in API level 24
public String getOverrideGroupKey ()

If the system has overridden the group key, then this will be non-null, and this key should be used to bundle notifications.

Returns
String

getRank

added in API level 21
public int getRank ()

Returns the rank of the notification.

Returns
int the rank of the notification, that is the 0-based index in the list of active notifications.

getSuppressedVisualEffects

added in API level 24
public int getSuppressedVisualEffects ()

Returns the type(s) of visual effects that should be suppressed for this notification. See NotificationManager.Policy, e.g. NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS.

Returns
int

getUserSentiment

added in API level 28
public int getUserSentiment ()

Returns how the system thinks the user feels about notifications from the channel provided by getChannel(). You can use this information to expose controls to help the user block this channel's notifications, if the sentiment is USER_SENTIMENT_NEGATIVE, or emphasize this notification if the sentiment is USER_SENTIMENT_POSITIVE.

Returns
int

isAmbient

added in API level 21
public boolean isAmbient ()

Returns whether the notification is an ambient notification, that is a notification that doesn't require the user's immediate attention.

Returns
boolean

isSuspended

added in API level 28
public boolean isSuspended ()

Returns whether the app that posted this notification is suspended, so this notification should be hidden.

Returns
boolean true if the notification should be hidden, false otherwise.

matchesInterruptionFilter

added in API level 21
public boolean matchesInterruptionFilter ()

Returns whether the notification matches the user's interruption filter.

Returns
boolean true if the notification is allowed by the filter, or false if it is blocked.