Summary: Constants | Inherited Constants | Fields | Ctors | Methods | Inherited Methods | [Expand All]
public class

# Message

extends Object
implements SafeParcelable

java.lang.Object
↳ | com.google.android.gms.nearby.messages.Message

## Class Overview

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.

##### See Also

- `publish(com.google.android.gms.common.api.GoogleApiClient, Message)`
- `subscribe(com.google.android.gms.common.api.GoogleApiClient, MessageListener)`

## Summary

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.
String | MESSAGE_NAMESPACE_RESERVED | A namespace reserved for special Messages.
String | MESSAGE_TYPE_EDDYSTONE_UID | See `includeEddystoneUids(String, String)` and `from(Message)`.
String | MESSAGE_TYPE_I_BEACON_ID | See `includeIBeaconIds(UUID, Short, Short)` and `from(Message)`.

[Expand] Inherited Constants
From interface com.google.android.gms.common.internal.safeparcel.SafeParcelable
String | NULL |
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |

Fields
public static final Creator<Message> | CREATOR |

Public Constructors
| Message(byte[] content) Creates a new message with the given content and the default type (empty string).
| Message(byte[] content, String type) Creates a new message with the given content and type.

Public Methods
boolean | equals(Object object) `Message` objects are equal if the namespace, type, and content are equal.
byte[] | getContent() Returns the raw bytes content of the message.
String | getNamespace() Returns the non-empty string for a public namespace or empty for the private one.
String | getType() Returns the type that describes the content of the message.
int | hashCode()
String | toString()
void | writeToParcel(Parcel out, int flags)

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Constants

#### public static final int MAX_CONTENT_SIZE_BYTES

The maximum content size in number of bytes.

Constant Value: 102400 (0x00019000)

#### public static final int MAX_TYPE_LENGTH

The maximum `length()` for the message type.

Constant Value: 32 (0x00000020)

#### public static final String MESSAGE_NAMESPACE_RESERVED

A namespace reserved for special Messages. See MESSAGE_TYPE_* for examples.

Constant Value: "__reserved_namespace"

#### public static final String MESSAGE_TYPE_EDDYSTONE_UID

See `includeEddystoneUids(String, String)` and `from(Message)`.

Constant Value: "__eddystone_uid"

#### public static final String MESSAGE_TYPE_I_BEACON_ID

See `includeIBeaconIds(UUID, Short, Short)` and `from(Message)`.

Constant Value: "__i_beacon_id"

## Fields

#### public static final Creator<Message> CREATOR

## Public Constructors

#### public Message (byte[] content)

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.

##### Parameters

content | An arbitrary array holding the content of the message. The maximum content size is `MAX_CONTENT_SIZE_BYTES`.

#### public Message (byte[] content, String type)

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.

##### Parameters

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`.

## Public Methods

#### public boolean equals (Object object)

`Message` objects are equal if the namespace, type, and content are equal.

#### public byte[] getContent ()

Returns the raw bytes content of the message.

#### public String getNamespace ()

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. See Beacons for more details on namespace and beacon attachment.

##### Returns

- An empty String for the private namespace or non-empty for public namespaces.

#### public String getType ()

Returns the type that describes the content of the message.

Returns an empty String if no type was specified when the message was created.

#### public int hashCode ()

#### public String toString ()

#### public void writeToParcel (Parcel out, int flags)