目录

MessageHandler

Class Info

public class MessageHandler extends Object

Callback processing class of the target message. It is triggered when the target message is discovered, lost, or the Bluetooth signal or distance of the device associated with the target message changes.

Public Constructor Summary

Constructor Name

public MessageHandler()

Creates an instance of MessageHandler.

Public Method Summary

Qualifier and Type

Method Name and Description

void

onBleSignalChanged(Message message, BleSignal bleSignal)

Called when a beacon is scanned for the first time or when the RSSI of a scanned beacon changes (the RSSI change exceeds 10 dBm).

void

onDistanceChanged(Message message, Distance distance)

Called when a beacon is scanned for the first time or when the distance of the beacon changes (exceeds the specified precision, for example, 1 meter).

void

onFound(Message message)

Called when a message is detected for the first time or a lost message (onLost) is detected again.

void

onLost(Message message)

Called when a message is no longer discoverable.

Public Constructors

[h2]MessageHandler

Constructor

public MessageHandler()

Creates an instance of MessageHandler.

Public Methods

[h2]onBleSignalChanged

Method

public void onBleSignalChanged(Message message, BleSignal bleSignal)

Called when a beacon is scanned for the first time or when the RSSI of a scanned beacon changes (the RSSI change exceeds 10 dBm).

This callback currently supports only BLE beacon messages. It does not support PendingIntent during subscription.

Parameters

Name

Description

message

Object of a published message.

bleSignal

BLE signals, including RSSI and TxPower.

[h2]onDistanceChanged

Method

public void onDistanceChanged(Message message, Distance distance)

Called when a beacon is scanned for the first time or when the distance of the beacon changes (exceeds the specified precision, for example, 1 meter).

This callback currently supports only BLE beacon messages. It does not support PendingIntent during subscription.

Parameters

Name

Description

message

Object of a published message.

distance

Updated estimated distance.

[h2]onFound

Method

public void onFound(Message message)

Called when a message is detected for the first time or a lost message is detected again.

Parameters

Name

Description

message

Object of a published message.

[h2]onLost

Method

public void onLost(Message message)

Called when a message is no longer discoverable.

This callback currently suits BLE beacon messages the best. For other messages, it may not respond in a timely manner. The method is called back only once unless a message is no longer detectable.

Parameters

Name

Description

message

Message.