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 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. |
int |
VISIBILITY_NO_OVERRIDE
Value signifying that the user and device policy manager have not expressed a lockscreen visibility override for a notification. |
Public constructors | |
---|---|
Ranking()
|
Public methods | |
---|---|
boolean
|
canBubble()
Returns whether the user has allowed bubbles globally, at the app level, and at the channel level for this notification. |
boolean
|
canShowBadge()
Returns whether this notification can be displayed as a badge. |
boolean
|
equals(Object o)
Indicates whether some other object is "equal to" this one. |
NotificationChannel
|
getChannel()
Returns the notification channel this notification was posted to, which dictates notification behavior and presentation. |
ShortcutInfo
|
getConversationShortcutInfo()
Returns the shortcut information associated with this notification, if it is a
|
int
|
getImportance()
Returns the importance of the notification, which dictates its
modes of presentation, see: |
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. |
long
|
getLastAudiblyAlertedMillis()
Returns the last time this notification alerted the user via sound or vibration. |
int
|
getLockscreenVisibilityOverride()
Returns the user or device policy manager specified visibility (see
|
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. |
List<Notification.Action>
|
getSmartActions()
Returns a list of smart |
List<CharSequence>
|
getSmartReplies()
Returns a list of smart replies that can be added by the notification assistant. |
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 |
boolean
|
isAmbient()
Returns whether the notification is an ambient notification, that is a notification that doesn't require the user's immediate attention. |
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. |
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
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
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
public static final int USER_SENTIMENT_POSITIVE
The user is likely to have a positive reaction to this notification.
Constant Value: 1 (0x00000001)
VISIBILITY_NO_OVERRIDE
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.
Constant Value: -1000 (0xfffffc18)
Public constructors
Public methods
canBubble
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.
Returns | |
---|---|
boolean |
canShowBadge
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. |
equals
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 returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
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 | |
---|---|
o |
Object : This value may be null . |
Returns | |
---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
getChannel
public NotificationChannel getChannel ()
Returns the notification channel this notification was posted to, which dictates notification behavior and presentation.
Returns | |
---|---|
NotificationChannel |
getConversationShortcutInfo
public ShortcutInfo getConversationShortcutInfo ()
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.
Returns | |
---|---|
ShortcutInfo |
getImportance
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 NotificationManager.IMPORTANCE_UNSPECIFIED , NotificationManager.IMPORTANCE_NONE , NotificationManager.IMPORTANCE_MIN , NotificationManager.IMPORTANCE_LOW , NotificationManager.IMPORTANCE_DEFAULT , or NotificationManager.IMPORTANCE_HIGH |
getImportanceExplanation
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
public String getKey ()
Returns the key of the notification this Ranking applies to.
Returns | |
---|---|
String |
getLastAudiblyAlertedMillis
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.
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. |
getLockscreenVisibilityOverride
public int getLockscreenVisibilityOverride ()
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.
Returns | |
---|---|
int |
Value is Notification.VISIBILITY_PUBLIC , Notification.VISIBILITY_PRIVATE , Notification.VISIBILITY_SECRET , or android.app.NotificationManager.VISIBILITY_NO_OVERRIDE |
getOverrideGroupKey
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
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. |
getSmartActions
public List<Notification.Action> getSmartActions ()
Returns a list of smart Notification.Action
that can be added by the
notification assistant.
Returns | |
---|---|
List<Notification.Action> |
This value cannot be null . |
getSmartReplies
public List<CharSequence> getSmartReplies ()
Returns a list of smart replies that can be added by the notification assistant.
Returns | |
---|---|
List<CharSequence> |
This value cannot be null . |
getSuppressedVisualEffects
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
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
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 |
isConversation
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.
Returns | |
---|---|
boolean |
isSuspended
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
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. |