目录

CLASS info
public class Message implements Parcelable
Represents the message that will be shared with nearby devices. The message consists of client-specified content and a type. The type can be used in MessageFilter.Builder to limit which messages an app can receive in a subscription.

Constant Summary

TypeNameDesc
intMAX_CONTENT_SIZEMaximum size of the message content, in bytes.
intMAX_TYPE_LENGTHMaximum size of a message type, in bytes.
StringMESSAGE_NAMESPACE_RESERVEDNamespace reserved for special messages. For details, please refer to MESSAGE_TYPE_*.
StringMESSAGE_TYPE_EDDYSTONE_UIDFor details, please refer to includeEddystoneUids(String, String) and parse(Message).
StringMESSAGE_TYPE_IBEACON_IDFor details, please refer to includeIBeaconIds(UUID, Short, Short) and parse(Message).

Field Summary

TypeNameDesc
public static final Creator<Message>CREATOR

Public Constructor Summary

Constructor name
public Message(byte[] content)
Creates a message with the specified content and the default type. Use this constructor when your app uses the default type to communicate with nearby devices. Parameters:
content: message content. The size cannot exceed MAX_CONTENT_SIZE.
public Message(byte[] content, String type)
Creates a message based on the given content and message type.Parameters:
content: message content. The size cannot exceed MAX_CONTENT_SIZE.
type: message type. The value cannot exceed MAX_TYPE_LENGTH.

Public Method Summary

ReturnMethod
booleanequals(Object other)
Checks whether any other object is the same as this object.
byte[]getContent()
Returns the message content.
StringgetNamespace()
Returns the non-empty string for a public namespace or an empty string for the private namespace. For example, a beacon attachment is a public namespace.
StringgetType()
Returns the message type. An empty string is returned if no type is specified when the message is created.
inthashCode()
Obtains the hash value.
StringtoString()
Converts an object into a readable character string.
voidwriteToParcel(Parcel out, int flags)
Writes this value into an out parcel.

Constants

Constant
public static final int MAX_CONTENT_SIZE
Maximum size of the message content, in bytes.
Constant value: 64
Constant
public static final int MAX_TYPE_LENGTH
Maximum size of a message type, in bytes.
Constant value: 16
Constant
public static final String MESSAGE_NAMESPACE_RESERVED
Namespace reserved for special messages. For details, please refer to MESSAGE_TYPE_*.
Constant value: “_reserved_namespace”
Constant
public static final String MESSAGE_TYPE_EDDYSTONE_UID
For details, please refer to includeEddystoneUids(String, String) and parse(Message).
Constant value: “_eddystone_uid”
Constant
public static final String MESSAGE_TYPE_IBEACON_ID
For details, please refer to includeIBeaconIds(String, String) and parse(Message).
Constant value: “_ibeacon_id”

Public Constructors

Constructor
public Message(byte[] content)
Creates a message with the specified content and the default type.

Parameters

Parameter nameParameter desc
contentMessage content. The size cannot exceed MAX_CONTENT_SIZE.
Constructor
public Message(byte[] content, String type)
Creates a message based on the given content and message type.

Parameters

Parameter nameParameter desc
contentMessage content. The size cannot exceed MAX_CONTENT_SIZE.
typeMessage type. The value cannot exceed MAX_TYPE_LENGTH.

Public Methods

Method
public boolean equals(Object other)
Checks whether any other object is the same as this object.

Parameters

Parameter nameParameter desc
otherOther object.
Method
public byte[] getContent()
Returns the message content.
Method
public String getNamespace()
Returns the non-empty string for a public namespace or an empty string for the private namespace. For example, a beacon attachment is a public namespace.
Method
public String getType()
Returns the message type. An empty string is returned if no type is specified when the message is created.
Method
public int hashCode()
Obtains the hash value.
Method
public String toString()
Converts an object into a readable character string.
Method
public void writeToParcel(Parcel out, int flags)
Writes this value into an out parcel.

Parameters

Parameter nameParameter desc
outParcel to which this object is written.
flagsWriting mode.