java.lang.Object | |
↳ | com.google.android.gms.nearby.messages.Message |
A message that will be shared with nearby devices. This message consists of
some client-specified content and a type. The type can be used in the
MessageFilter.Builder
to limit which messages an application receives
in a subscription.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MAX_CONTENT_SIZE_BYTES | The maximum content size in number of bytes. | |||||||||
int | MAX_TYPE_LENGTH |
The maximum length() for the message type.
|
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new message with the given content and the default type (empty string).
| |||||||||||
Creates a new message with the given content and type.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Message objects are equal if the namespace, type, and content are equal.
| |||||||||||
Returns the raw bytes content of the message.
| |||||||||||
Returns the non-empty string for a public namespace or empty for the private one.
| |||||||||||
Returns the type that describes the content of the message.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
The maximum content size in number of bytes.
The maximum length()
for the message type.
Creates a new message with the given content and the default type (empty string).
Use this constructor when the application has only one message type or as the default type to exchange with nearby devices.
content | An arbitrary array holding the content of the message.
The maximum content size is MAX_CONTENT_SIZE_BYTES .
|
---|
Creates a new message with the given content and type.
Use this constructor when your application has multiple types of data to exchange. For example, a poll application could publish a message with type "question", and subscribe for messages of type "answer" that are published by the same app running on other nearby devices.
content | An arbitrary array holding the content of the message.
The maximum content size is MAX_CONTENT_SIZE_BYTES . |
---|---|
type | A string that describe what the bytes of the content represent.
The maximum type length is MAX_TYPE_LENGTH .
|
Message
objects are equal if the namespace, type, and content are equal.
Returns the raw bytes content of the message.
Returns the non-empty string for a public namespace or empty for the private one. The private namespace contains messages are meant to be used and exchanged by apps that created them.
A public namespace contains messages that are publicly known and is accessible to any application who is interested in them. One example of a message in a public namespace is a beacon attachment.
Returns the type that describes the content of the message.
Returns an empty String if no type was specified when the message was created.