public
static
class
NotificationCompat.MessagingStyle
extends NotificationCompat.Style
java.lang.Object | ||
↳ | android.support.v4.app.NotificationCompat.Style | |
↳ | android.support.v4.app.NotificationCompat.MessagingStyle |
Helper class for generating large-format notifications that include multiple back-and-forth
messages of varying types between any number of people.
If the platform does not provide large-format notifications, this method has no effect. The
user will always see the normal notification view.
This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like
so:
Notification noti = new Notification.Builder() .setContentTitle("2 new messages wtih " + sender.toString()) .setContentText(subject) .setSmallIcon(R.drawable.new_message) .setLargeIcon(aBitmap) .setStyle(new Notification.MessagingStyle(resources.getString(R.string.reply_name)) .addMessage(messages[0].getText(), messages[0].getTime(), messages[0].getSender()) .addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getSender())) .build();
Nested classes | |
---|---|
class |
NotificationCompat.MessagingStyle.Message
|
Constants | |
---|---|
int |
MAXIMUM_RETAINED_MESSAGES
The maximum number of messages that will be retained in the Notification itself (the number displayed is up to the platform). |
Public constructors | |
---|---|
NotificationCompat.MessagingStyle(CharSequence userDisplayName)
|
Public methods | |
---|---|
void
|
addCompatExtras(Bundle extras)
|
NotificationCompat.MessagingStyle
|
addMessage(CharSequence text, long timestamp, CharSequence sender)
Adds a message for display by this notification. |
NotificationCompat.MessagingStyle
|
addMessage(NotificationCompat.MessagingStyle.Message message)
Adds a |
static
NotificationCompat.MessagingStyle
|
extractMessagingStyleFromNotification(Notification notif)
Retrieves a |
CharSequence
|
getConversationTitle()
Return the title to be displayed on this conversation. |
List<NotificationCompat.MessagingStyle.Message>
|
getMessages()
Gets the list of |
CharSequence
|
getUserDisplayName()
Returns the name to be displayed for any replies sent by the user |
NotificationCompat.MessagingStyle
|
setConversationTitle(CharSequence conversationTitle)
Sets the title to be displayed on this conversation. |
Inherited methods | |
---|---|
From
class
android.support.v4.app.NotificationCompat.Style
| |
From
class
java.lang.Object
|
int MAXIMUM_RETAINED_MESSAGES
The maximum number of messages that will be retained in the Notification itself (the number displayed is up to the platform).
Constant Value: 25 (0x00000019)
NotificationCompat.MessagingStyle (CharSequence userDisplayName)
Parameters | |
---|---|
userDisplayName |
CharSequence :
the name to be displayed for any replies sent by the user before the
posting app reposts the notification with those messages after they've been actually
sent and in previous messages sent by the user added in
addMessage(Message)
|
NotificationCompat.MessagingStyle addMessage (CharSequence text, long timestamp, CharSequence sender)
Adds a message for display by this notification. Convenience call for a simple
NotificationCompat.MessagingStyle.Message
in addMessage(Message)
Parameters | |
---|---|
text |
CharSequence :
A CharSequence to be displayed as the message content |
timestamp |
long :
Time at which the message arrived |
sender |
CharSequence :
A CharSequence to be used for displaying the name of the
sender. Should be null for messages by the current user, in which case
the platform will insert getUserDisplayName() .
Should be unique amongst all individuals in the conversation, and should be
consistent during re-posts of the notification. |
Returns | |
---|---|
NotificationCompat.MessagingStyle |
this object for method chaining |
NotificationCompat.MessagingStyle addMessage (NotificationCompat.MessagingStyle.Message message)
Adds a NotificationCompat.MessagingStyle.Message
for display in this notification.
Parameters | |
---|---|
message |
NotificationCompat.MessagingStyle.Message :
The NotificationCompat.MessagingStyle.Message to be displayed |
Returns | |
---|---|
NotificationCompat.MessagingStyle |
this object for method chaining |
NotificationCompat.MessagingStyle extractMessagingStyleFromNotification (Notification notif)
Retrieves a NotificationCompat.MessagingStyle
from a Notification
, enabling an application
that has set a NotificationCompat.MessagingStyle
using NotificationCompat
or
Notification.Builder
to send messaging information to another
application using NotificationCompat
, regardless of the API level of the system.
Returns null
if there is no NotificationCompat.MessagingStyle
set.
Parameters | |
---|---|
notif |
Notification
|
Returns | |
---|---|
NotificationCompat.MessagingStyle |
CharSequence getConversationTitle ()
Return the title to be displayed on this conversation. Can be null
and
should be for one-on-one conversations
Returns | |
---|---|
CharSequence |
List<NotificationCompat.MessagingStyle.Message> getMessages ()
Gets the list of Message
objects that represent the notification
Returns | |
---|---|
List<NotificationCompat.MessagingStyle.Message> |
CharSequence getUserDisplayName ()
Returns the name to be displayed for any replies sent by the user
Returns | |
---|---|
CharSequence |
NotificationCompat.MessagingStyle setConversationTitle (CharSequence conversationTitle)
Sets the title to be displayed on this conversation. This should only be used for group messaging and left unset for one-on-one conversations.
Returns | |
---|---|
NotificationCompat.MessagingStyle |
this object for method chaining. |