Chat Android SDK  7.0.1
com.twilio.chat.Message.Options Class Reference

Used to construct new message before sending. More...

Public Member Functions

Options withBody (String body)
 Create message with given body text. More...
 
Options withAttributes (Attributes attributes)
 Set new message attributes. More...
 
Options withMedia (InputStream in, String mimeType)
 Create message with given media stream. More...
 
Options withMediaFileName (String filename)
 Provide optional filename for media. More...
 
Options withMediaProgressListener (ProgressListener listener)
 Set upload progress listener for media. More...
 

Detailed Description

Used to construct new message before sending.

To avoid races between message create and send the SDK first collects all information about the message to create and then creates and sends the message in a single operation.

There are two major types of messages: TEXT and MEDIA.

Member Function Documentation

Options com.twilio.chat.Message.Options.withAttributes ( Attributes  attributes)

Set new message attributes.

Parameters
attributesAttributes for the message.
Returns
Self for chaining.
Options com.twilio.chat.Message.Options.withBody ( String  body)

Create message with given body text.

If you specify withBody() then you will not be able to specify withMedia() because they are mutually exclusive message types. Created message type will be Message::Type::TEXT.

Parameters
bodyMessage text body.
Returns
Self for chaining.
Options com.twilio.chat.Message.Options.withMedia ( InputStream  in,
String  mimeType 
)

Create message with given media stream.

If you specify withMedia() then you will not be able to specify withBody because they are mutually exclusive message types. Created message type will be Message.Type#MEDIA.

After media message is sent, other clients are able to request temporary URL to media content by Message::Media::getContentTemporaryUrl() and then download it.

Parameters
inInput stream to read media data from. Provided stream could be any subclass of java.io.InputStream including ByteArrayInputStream, so you could upload media from memory or even generate it on the go.
mimeTypeMIME type for the media. Media service supports popular text, picture and video formats.
Returns
Self for chaining.
Exceptions
IllegalStateExceptionWhen attempt is made to set media on a text-only message.
IllegalArgumentExceptionWhen attempt is made to use null input stream.
Options com.twilio.chat.Message.Options.withMediaFileName ( String  filename)

Provide optional filename for media.

Parameters
filename[description]
Returns
Self for chaining.
Options com.twilio.chat.Message.Options.withMediaProgressListener ( ProgressListener  listener)

Set upload progress listener for media.

Parameters
listener[description]
Returns
Self for chaining.