RangingManager


class RangingManager
kotlin.Any
   ↳ android.ranging.RangingManager

This class provides a way to perform ranging operations such as querying the device's capabilities and determining the distance and angle between the local device and a remote device.

To get a RangingManager, call the Context.getSystemService(RangingManager.class).

Summary

Nested classes
abstract

Callback interface to receive the availabilities and capabilities of all the ranging technology supported by the device.

Constants
static Int

Bluetooth Channel Sounding (BT-CS) technology.

static Int

Bluetooth Low Energy (BLE) RSSI-based ranging technology.

static Int

Ultra-Wideband (UWB) technology.

static Int

WiFi Round Trip Time (WiFi-RTT) technology.

Public methods
RangingSession?

Creates a new ranging session.

Unit

Registers a callback to receive ranging capabilities updates.

Unit

Unregisters a previously registered ranging capabilities callback.

Constants

BLE_CS

static val BLE_CS: Int

Bluetooth Channel Sounding (BT-CS) technology.

Value: 1

BLE_RSSI

static val BLE_RSSI: Int

Bluetooth Low Energy (BLE) RSSI-based ranging technology.

Value: 3

UWB

static val UWB: Int

Ultra-Wideband (UWB) technology.

Value: 0

WIFI_NAN_RTT

static val WIFI_NAN_RTT: Int

WiFi Round Trip Time (WiFi-RTT) technology.

Value: 2

Public methods

createRangingSession

fun createRangingSession(
    executor: Executor,
    callback: RangingSession.Callback
): RangingSession?

Creates a new ranging session. A ranging session enables the application to perform ranging operations using available technologies such as UWB (Ultra-Wideband) or WiFi RTT (Round Trip Time).

This method returns a RangingSession instance, which can be used to initiate, manage, and stop ranging operations. The provided RangingSession.Callback will be used to receive session-related events, such as session start, stop, and ranging updates.

It is recommended to provide an appropriate Executor to ensure that callback events are handled on a suitable thread.

Parameters
callback RangingSession.Callback: the RangingSession.Callback to handle session-related events. Must not be null.
executor Executor: the Executor on which the callback will be invoked. Must not be null.
Return
RangingSession? the RangingSession instance if the session was successfully created, or null if the session could not be created.
Exceptions
java.lang.NullPointerException if callback or executor is null.
java.lang.SecurityException if the calling app does not have the necessary permissions to create a ranging session.

registerCapabilitiesCallback

fun registerCapabilitiesCallback(
    executor: Executor,
    callback: RangingManager.RangingCapabilitiesCallback
): Unit

Registers a callback to receive ranging capabilities updates.

Parameters
executor Executor: The Executor on which the callback will be executed. Must not be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.
callback RangingManager.RangingCapabilitiesCallback: The RangingCapabilitiesCallback that will handle the capabilities updates. Must not be null.
Return
Unit This value cannot be null.
Exceptions
java.lang.NullPointerException if the executor or callback is null.

unregisterCapabilitiesCallback

fun unregisterCapabilitiesCallback(callback: RangingManager.RangingCapabilitiesCallback): Unit

Unregisters a previously registered ranging capabilities callback.

Parameters
callback RangingManager.RangingCapabilitiesCallback: The RangingCapabilitiesCallback to be unregistered. Must not be null.
Return
Unit This value cannot be null.
Exceptions
java.lang.NullPointerException if the callback is null.