Added in API level 21

Ranking


open class Ranking
kotlin.Any
   ↳ 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 RankingMap.

Summary

Constants
static Int

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

static Int

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

static Int

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

static Int

Value signifying that the user and device policy manager have not expressed a lockscreen visibility override for a notification.

Public constructors

Public methods
open Boolean

Returns whether the user has allowed bubbles globally, at the app level, and at the channel level for this notification.

open Boolean

Returns whether this notification can be displayed as a badge.

open Boolean
equals(other: Any?)

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

open NotificationChannel!

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

open ShortcutInfo?

Returns the shortcut information associated with this notification, if it is a conversation notification.

open Int

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

open CharSequence!

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

open String!

Returns the key of the notification this Ranking applies to.

open Long

Returns the last time this notification alerted the user via sound or vibration.

open Int

Returns the user or device policy manager specified visibility (see Notification.VISIBILITY_PRIVATE, Notification.VISIBILITY_PUBLIC, Notification.VISIBILITY_SECRET) for this notification, or NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE if no such preference has been expressed.

open String!

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

open Int

Returns the rank of the notification.

open MutableList<Notification.Action!>

Returns a list of smart Notification.Action that can be added by the notification assistant.

open MutableList<CharSequence!>

Returns a list of smart replies that can be added by the notification assistant.

open Int

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

open Int

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

open Boolean

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

open Boolean

Returns whether this notification is a conversation notification, and would appear in the conversation section of the notification shade, on devices that separate that type of notification.

open Boolean

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

open Boolean

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

Constants

USER_SENTIMENT_NEGATIVE

Added in API level 28
static val USER_SENTIMENT_NEGATIVE: Int

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

Value: -1

USER_SENTIMENT_NEUTRAL

Added in API level 28
static val USER_SENTIMENT_NEUTRAL: Int

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

Value: 0

USER_SENTIMENT_POSITIVE

Added in API level 28
static val USER_SENTIMENT_POSITIVE: Int

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

Value: 1

VISIBILITY_NO_OVERRIDE

Added in API level 31
static val VISIBILITY_NO_OVERRIDE: Int

Value signifying that the user and device policy manager have not expressed a lockscreen visibility override for a notification.

Value: -1000

Public constructors

Ranking

Added in API level 21
Ranking()

Public methods

canBubble

Added in API level 29
open fun canBubble(): Boolean

Returns whether the user has allowed bubbles globally, at the app level, and at the channel level for this notification.

This does not take into account the current importance of the notification, the current DND state, or whether the posting app is foreground.

canShowBadge

Added in API level 26
open fun canShowBadge(): Boolean

Returns whether this notification can be displayed as a badge.

Return
Boolean true if the notification can be displayed as a badge, false otherwise.

equals

Added in API level 21
open fun equals(other: Any?): Boolean

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

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
o This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getChannel

Added in API level 26
open fun getChannel(): NotificationChannel!

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

getConversationShortcutInfo

Added in API level 31
open fun getConversationShortcutInfo(): ShortcutInfo?

Returns the shortcut information associated with this notification, if it is a conversation notification.

This might be null even if the notification is a conversation notification, if the posting app hasn't opted into the full conversation feature set yet.

getImportanceExplanation

Added in API level 24
open fun getImportanceExplanation(): CharSequence!

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

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

getKey

Added in API level 21
open fun getKey(): String!

Returns the key of the notification this Ranking applies to.

getLastAudiblyAlertedMillis

Added in API level 29
open fun getLastAudiblyAlertedMillis(): Long

Returns the last time this notification alerted the user via sound or vibration.
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

Return
Long the time of the last alerting behavior, in milliseconds. Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

getLockscreenVisibilityOverride

Added in API level 31
open fun getLockscreenVisibilityOverride(): Int

Returns the user or device policy manager specified visibility (see Notification.VISIBILITY_PRIVATE, Notification.VISIBILITY_PUBLIC, Notification.VISIBILITY_SECRET) for this notification, or NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE if no such preference has been expressed.

Return
Int Value is android.app.Notification#VISIBILITY_PUBLIC, android.app.Notification#VISIBILITY_PRIVATE, android.app.Notification#VISIBILITY_SECRET, or android.app.NotificationManager.VISIBILITY_NO_OVERRIDE

getOverrideGroupKey

Added in API level 24
open fun getOverrideGroupKey(): String!

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

getRank

Added in API level 21
open fun getRank(): Int

Returns the rank of the notification.

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

getSmartActions

Added in API level 29
open fun getSmartActions(): MutableList<Notification.Action!>

Returns a list of smart Notification.Action that can be added by the notification assistant.

Return
MutableList<Notification.Action!> This value cannot be null.

getSmartReplies

Added in API level 29
open fun getSmartReplies(): MutableList<CharSequence!>

Returns a list of smart replies that can be added by the notification assistant.

Return
MutableList<CharSequence!> This value cannot be null.

getSuppressedVisualEffects

Added in API level 24
open fun getSuppressedVisualEffects(): Int

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

getUserSentiment

Added in API level 28
open fun getUserSentiment(): Int

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.

isAmbient

Added in API level 21
open fun isAmbient(): Boolean

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

isConversation

Added in API level 31
open fun isConversation(): Boolean

Returns whether this notification is a conversation notification, and would appear in the conversation section of the notification shade, on devices that separate that type of notification.

isSuspended

Added in API level 28
open fun isSuspended(): Boolean

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

Return
Boolean true if the notification should be hidden, false otherwise.

matchesInterruptionFilter

Added in API level 21
open fun matchesInterruptionFilter(): Boolean

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

Return
Boolean true if the notification is allowed by the filter, or false if it is blocked.