Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#constants) \| [Ctors](https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#pubctors) \| [Methods](https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#inhmethods)

# NotificationListenerService.Ranking

*** ** * ** ***


`
public
static


class
NotificationListenerService.Ranking
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.service.notification.NotificationListenerService.Ranking |

<br />

*** ** * ** ***

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/android/service/notification/NotificationListenerService.RankingMap`.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_NEGATIVE` The user is likely to have a negative reaction to this notification. |
| `int` | `https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_NEUTRAL` It is not known how the user will react to this notification. |
| `int` | `https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_POSITIVE` The user is likely to have a positive reaction to this notification. |
| `int` | `https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#VISIBILITY_NO_OVERRIDE` 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/android/service/notification/NotificationListenerService.Ranking#Ranking()() ` |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/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. |
| ` boolean` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#canShowBadge()() ` Returns whether this notification can be displayed as a badge. |
| ` boolean` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` Indicates whether some other object is "equal to" this one. |
| ` https://developer.android.com/reference/android/app/NotificationChannel` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getChannel()() ` Returns the notification channel this notification was posted to, which dictates notification behavior and presentation. |
| ` https://developer.android.com/reference/android/content/pm/ShortcutInfo` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getConversationShortcutInfo()() ` Returns the shortcut information associated with this notification, if it is a `https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#isConversation()`. |
| ` int` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getImportance()() ` Returns the importance of the notification, which dictates its modes of presentation, see: `https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT`, etc. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getImportanceExplanation()() ` If the importance has been overridden by user preference, then this will be non-null. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getKey()() ` Returns the key of the notification this Ranking applies to. |
| ` long` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getLastAudiblyAlertedMillis()() ` Returns the last time this notification alerted the user via sound or vibration. |
| ` int` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getLockscreenVisibilityOverride()() ` Returns the user or device policy manager specified visibility (see `https://developer.android.com/reference/android/app/Notification#VISIBILITY_PRIVATE`, `https://developer.android.com/reference/android/app/Notification#VISIBILITY_PUBLIC`, `https://developer.android.com/reference/android/app/Notification#VISIBILITY_SECRET`) for this notification, or `https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#VISIBILITY_NO_OVERRIDE` if no such preference has been expressed. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/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. |
| ` int` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getRank()() ` Returns the rank of the notification. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/Notification.Action>` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getSmartActions()() ` Returns a list of smart `https://developer.android.com/reference/android/app/Notification.Action` that can be added by the notification assistant. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/CharSequence>` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getSmartReplies()() ` Returns a list of smart replies that can be added by the notification assistant. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/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). |
| ` int` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#getSuppressedVisualEffects()() ` Returns the type(s) of visual effects that should be suppressed for this notification. |
| ` int` | ` https://developer.android.com/reference/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/android/service/notification/NotificationListenerService.Ranking#getChannel()`. |
| ` boolean` | ` https://developer.android.com/reference/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. |
| ` boolean` | ` https://developer.android.com/reference/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. |
| ` boolean` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#isSuspended()() ` Returns whether the app that posted this notification is suspended, so this notification should be hidden. |
| ` boolean` | ` https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#matchesInterruptionFilter()() ` Returns whether the notification matches the user's interruption filter. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

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


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

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


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

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


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

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


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

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


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

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


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Constants

### USER_SENTIMENT_NEGATIVE

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

```
public static final int USER_SENTIMENT_NEGATIVE
```

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

<br />

Constant Value:

-1
(0xffffffff)


### USER_SENTIMENT_NEUTRAL

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

```
public static final int USER_SENTIMENT_NEUTRAL
```

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

<br />

Constant Value:

0
(0x00000000)


### USER_SENTIMENT_POSITIVE

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

```
public static final int USER_SENTIMENT_POSITIVE
```

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

<br />

Constant Value:

1
(0x00000001)


### VISIBILITY_NO_OVERRIDE

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

```
public static final int VISIBILITY_NO_OVERRIDE
```

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

<br />

Constant Value:

-1000
(0xfffffc18)


## Public constructors

### Ranking

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

```
public Ranking ()
```

<br />

<br />

## Public methods

### canBubble

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

```
public boolean canBubble ()
```

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.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### canShowBadge

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

```
public boolean canShowBadge ()
```

Returns whether this notification can be displayed as a badge.

<br />

| Returns ||
|---|---|
| `boolean` | true if the notification can be displayed as a badge, false otherwise. <br /> |

### equals

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

```
public boolean equals (Object o)
```

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.

<br />

| Parameters ||
|---|---|
| `o` | `Object`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### getChannel

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

```
public NotificationChannel getChannel ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/NotificationChannel` | <br /> |

### getConversationShortcutInfo

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

```
public ShortcutInfo getConversationShortcutInfo ()
```

Returns the shortcut information associated with this notification, if it is a
`https://developer.android.com/reference/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.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/pm/ShortcutInfo` | <br /> |

### getImportance

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

```
public int getImportance ()
```

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

<br />

| Returns ||
|---|---|
| `int` | the importance of the notification. Value is one of the following: - `https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_UNSPECIFIED` - `https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_NONE` - `https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_MIN` - `https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_LOW` - `https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT` - `https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_HIGH` |

### getImportanceExplanation

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

```
public CharSequence getImportanceExplanation ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | the explanation for the importance, or null if it is the natural importance <br /> |

### getKey

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

```
public String getKey ()
```

Returns the key of the notification this Ranking applies to.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getLastAudiblyAlertedMillis

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

```
public long getLastAudiblyAlertedMillis ()
```

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.

<br />

| Returns ||
|---|---|
| `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. <br /> |

### getLockscreenVisibilityOverride

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

```
public int getLockscreenVisibilityOverride ()
```

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

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/app/Notification#VISIBILITY_PUBLIC` - `https://developer.android.com/reference/android/app/Notification#VISIBILITY_PRIVATE` - `https://developer.android.com/reference/android/app/Notification#VISIBILITY_SECRET` |

### getOverrideGroupKey

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

```
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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getRank

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

```
public int getRank ()
```

Returns the rank of the notification.

<br />

| Returns ||
|---|---|
| `int` | the rank of the notification, that is the 0-based index in the list of active notifications. <br /> |

### getSmartActions

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

```
public List<Notification.Action> getSmartActions ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/Notification.Action>` | This value cannot be `null`. <br /> |

### getSmartReplies

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

```
public List<CharSequence> getSmartReplies ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/CharSequence>` | This value cannot be `null`. <br /> |

### getSummarization

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public String 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).

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value may be `null`. <br /> |

### getSuppressedVisualEffects

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

```
public int getSuppressedVisualEffects ()
```

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

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getUserSentiment

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

```
public int getUserSentiment ()
```

Returns how the system thinks the user feels about notifications from the
channel provided by `https://developer.android.com/reference/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/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_NEGATIVE`, or emphasize this notification if the sentiment is
`https://developer.android.com/reference/android/service/notification/NotificationListenerService.Ranking#USER_SENTIMENT_POSITIVE`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### isAmbient

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

```
public boolean isAmbient ()
```

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

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isConversation

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

```
public boolean 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.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isSuspended

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

```
public boolean isSuspended ()
```

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

<br />

| Returns ||
|---|---|
| `boolean` | true if the notification should be hidden, false otherwise. <br /> |

### matchesInterruptionFilter

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

```
public boolean matchesInterruptionFilter ()
```

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

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the notification is allowed by the filter, or `false` if it is blocked. <br /> |