Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Ranking

*** ** * ** ***

```
open class Ranking
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.service.notification.NotificationListenerService.Ranking](https://developer.android.com/reference/kotlin/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 `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.RankingMap`.

## Summary

| Constants ||
|---|---|
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_NEGATIVE:kotlin.Int` The user is likely to have a negative reaction to this notification. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_NEUTRAL:kotlin.Int` It is not known how the user will react to this notification. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_POSITIVE:kotlin.Int` The user is likely to have a positive reaction to this notification. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#VISIBILITY_NO_OVERRIDE:kotlin.Int` Value signifying that the user and device policy manager have not expressed a lockscreen visibility override for a notification. |

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#Ranking()()` <br /> |

| Public methods ||
|---|---|
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#canBubble()()` Returns whether the user has allowed bubbles globally, at the app level, and at the channel level for this notification. |
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#canShowBadge()()` Returns whether this notification can be displayed as a badge. |
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#equals(kotlin.Any)(other: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?)` Indicates whether some other object is "equal to" this one. |
| open [NotificationChannel](https://developer.android.com/reference/kotlin/android/app/NotificationChannel.html#)! | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getChannel()()` Returns the notification channel this notification was posted to, which dictates notification behavior and presentation. |
| open [ShortcutInfo](https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo.html#)? | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getConversationShortcutInfo()()` Returns the shortcut information associated with this notification, if it is a `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#isConversation()`. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getImportance()()` Returns the importance of the notification, which dictates its modes of presentation, see: `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_DEFAULT:kotlin.Int`, etc. |
| open [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)! | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getImportanceExplanation()()` If the importance has been overridden by user preference, then this will be non-null. |
| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getKey()()` Returns the key of the notification this Ranking applies to. |
| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getLastAudiblyAlertedMillis()()` Returns the last time this notification alerted the user via sound or vibration. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getLockscreenVisibilityOverride()()` Returns the user or device policy manager specified visibility (see `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_PRIVATE:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_PUBLIC:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_SECRET:kotlin.Int`) for this notification, or `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#VISIBILITY_NO_OVERRIDE:kotlin.Int` if no such preference has been expressed. |
| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getOverrideGroupKey()()` 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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getRank()()` Returns the rank of the notification. |
| open [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Notification.Action](https://developer.android.com/reference/kotlin/android/app/Notification.Action.html#)!\> | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getSmartActions()()` Returns a list of smart `https://developer.android.com/reference/kotlin/android/app/Notification.Action.html#` that can be added by the notification assistant. |
| open [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!\> | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getSmartReplies()()` Returns a list of smart replies that can be added by the notification assistant. |
| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getSummarization()()` Returns a summary of the content in the notification, or potentially of the current notification and related notifications (for example, if this is provided for a group summary notification it may be summarizing all the child notifications). |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getSuppressedVisualEffects()()` Returns the type(s) of visual effects that should be suppressed for this notification. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getUserSentiment()()` Returns how the system thinks the user feels about notifications from the channel provided by `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getChannel()`. |
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#isAmbient()()` Returns whether the notification is an ambient notification, that is a notification that doesn't require the user's immediate attention. |
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#isConversation()()` 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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#isSuspended()()` Returns whether the app that posted this notification is suspended, so this notification should be hidden. |
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#matchesInterruptionFilter()()` Returns whether the notification matches the user's interruption filter. |

## Constants

### USER_SENTIMENT_NEGATIVE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Ranking()
```

## Public methods

### canBubble

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun canShowBadge(): Boolean
```

Returns whether this notification can be displayed as a badge.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | true if the notification can be displayed as a badge, false otherwise. |

### equals

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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 ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `true` if this object is the same as the obj argument; `false` otherwise. |

### getChannel

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getConversationShortcutInfo(): ShortcutInfo?
```

Returns the shortcut information associated with this notification, if it is a `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#isConversation()`.

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.

### getImportance

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getImportance(): Int
```

Returns the importance of the notification, which dictates its modes of presentation, see: `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_DEFAULT:kotlin.Int`, etc.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | the importance of the notification. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_UNSPECIFIED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_NONE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_MIN:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_LOW:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_DEFAULT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#IMPORTANCE_HIGH:kotlin.Int` |

### getImportanceExplanation

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getImportanceExplanation(): CharSequence!
```

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

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html!` | the explanation for the importance, or null if it is the natural importance |

### getKey

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getKey(): String!
```

Returns the key of the notification this Ranking applies to.

### getLastAudiblyAlertedMillis

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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 ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html` | 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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getLockscreenVisibilityOverride(): Int
```

Returns the user or device policy manager specified visibility (see `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_PRIVATE:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_PUBLIC:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_SECRET:kotlin.Int`) for this notification, or `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#VISIBILITY_NO_OVERRIDE:kotlin.Int` if no such preference has been expressed.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_PUBLIC:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_PRIVATE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.html#VISIBILITY_SECRET:kotlin.Int` |

### getOverrideGroupKey

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getRank(): Int
```

Returns the rank of the notification.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | the rank of the notification, that is the 0-based index in the list of active notifications. |

### getSmartActions

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getSmartActions(): MutableList<Notification.Action!>
```

Returns a list of smart `https://developer.android.com/reference/kotlin/android/app/Notification.Action.html#` that can be added by the notification assistant.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/app/Notification.Action.html#!>` | This value cannot be `null`. |

### getSmartReplies

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getSmartReplies(): MutableList<CharSequence!>
```

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

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html!>` | This value cannot be `null`. |

### getSummarization

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getSummarization(): String?
```

Returns a summary of the content in the notification, or potentially of the current notification and related notifications (for example, if this is provided for a group summary notification it may be summarizing all the child notifications).

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | This value may be `null`. |

### getSuppressedVisualEffects

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getSuppressedVisualEffects(): Int
```

Returns the type(s) of visual effects that should be suppressed for this notification. See `https://developer.android.com/reference/kotlin/android/app/NotificationManager.Policy.html#`, e.g. `https://developer.android.com/reference/kotlin/android/app/NotificationManager.Policy.html#SUPPRESSED_EFFECT_LIGHTS:kotlin.Int`.

### getUserSentiment

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getUserSentiment(): Int
```

Returns how the system thinks the user feels about notifications from the channel provided by `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#getChannel()`. You can use this information to expose controls to help the user block this channel's notifications, if the sentiment is `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_NEGATIVE:kotlin.Int`, or emphasize this notification if the sentiment is `https://developer.android.com/reference/kotlin/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_POSITIVE:kotlin.Int`.

### isAmbient

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun isSuspended(): Boolean
```

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

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | true if the notification should be hidden, false otherwise. |

### matchesInterruptionFilter

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun matchesInterruptionFilter(): Boolean
```

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

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `true` if the notification is allowed by the filter, or `false` if it is blocked. |