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

# MessageListener

extends Object

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

## Class Overview

A listener for receiving subscribed messages. These callbacks will be delivered when messages are found or lost.

## Summary

Public Constructors
| MessageListener()

Public Methods
void | onBleSignalChanged(Message message, BleSignal bleSignal) Called when the Bluetooth Low Energy (BLE) signal associated with a message changes.
void | onDistanceChanged(Message message, Distance distance) Called when Nearby's estimate of the distance to a message changes.
abstract void | onFound(Message message) Called when messages are found.
void | onLost(Message message) Called when a message is no longer detectable nearby.

[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()

## Public Constructors

#### public MessageListener ()

## Public Methods

#### public void onBleSignalChanged (Message message, BleSignal bleSignal)

Called when the Bluetooth Low Energy (BLE) signal associated with a message changes.

For example, this is called when we see the first BLE advertisement frame associated with a message; or when we see subsequent frames with different RSSI.

This will only be called if we discover that the message is nearby via a BLE signal. For messages discovered in other ways (e.g. audio), this will not be called.

Note: This callback is not supported by the version of `subscribe(GoogleApiClient, PendingIntent)` that takes a `PendingIntent`.

#### public void onDistanceChanged (Message message, Distance distance)

Called when Nearby's estimate of the distance to a message changes.

For example, this is called when we first gather enough information to make a distance estimate; or when the message remains nearby, but gets closer or further away.

Note: This callback is not supported by the version of `subscribe(GoogleApiClient, PendingIntent)` that takes a `PendingIntent`.

##### Parameters

message | The message whose distance changed.
distance | The new distance estimate.

#### public abstract void onFound (Message message)

Called when messages are found.

This method is called the first time the message is seen nearby. After a message has been lost (see `onLost(Message)`), it's eligible for `onFound(Message)` again.

##### Parameters

message | The found message.

#### public void onLost (Message message)

Called when a message is no longer detectable nearby.

Note: This callback currently works best for messages attached to BLE beacons. For other messages, it may not be called in a timely fashion, or at all.

This method will not be called repeatedly (unless the message is found again between lost calls).

##### Parameters

message | The lost message.