RangingManager
public
final
class
RangingManager
extends Object
| java.lang.Object | |
| ↳ | 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).
Restricted for SDK Runtime environment in API level 36.
Summary
Nested classes | |
|---|---|
interface |
RangingManager.RangingCapabilitiesCallback
Callback interface to receive the availabilities and capabilities of all the ranging technology supported by the device. |
Constants | |
|---|---|
int |
BLE_CS
Bluetooth Channel Sounding (BT-CS) technology. |
int |
BLE_RSSI
Bluetooth Low Energy (BLE) RSSI-based ranging technology. |
int |
UWB
Ultra-Wideband (UWB) technology. |
int |
WIFI_NAN_RTT
WiFi Round Trip Time (WiFi-RTT) technology. |
int |
WIFI_STA_RTT
WiFi Round Trip Time (WiFi-RTT 8011MC) technology. |
Public methods | |
|---|---|
RangingSession
|
createRangingSession(Executor executor, RangingSession.Callback callback)
Creates a new ranging session. |
void
|
registerCapabilitiesCallback(Executor executor, RangingManager.RangingCapabilitiesCallback callback)
Registers a callback to receive ranging capabilities updates. |
void
|
unregisterCapabilitiesCallback(RangingManager.RangingCapabilitiesCallback callback)
Unregisters a previously registered ranging capabilities callback. |
Inherited methods | |
|---|---|
Constants
BLE_CS
public static final int BLE_CS
Bluetooth Channel Sounding (BT-CS) technology.
Constant Value: 1 (0x00000001)
BLE_RSSI
public static final int BLE_RSSI
Bluetooth Low Energy (BLE) RSSI-based ranging technology.
Constant Value: 3 (0x00000003)
UWB
public static final int UWB
Ultra-Wideband (UWB) technology.
Constant Value: 0 (0x00000000)
WIFI_NAN_RTT
public static final int WIFI_NAN_RTT
WiFi Round Trip Time (WiFi-RTT) technology.
Constant Value: 2 (0x00000002)
WIFI_STA_RTT
public static final int WIFI_STA_RTT
WiFi Round Trip Time (WiFi-RTT 8011MC) technology.
Constant Value: 4 (0x00000004)
Public methods
createRangingSession
public RangingSession createRangingSession (Executor executor, RangingSession.Callback callback)
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 | |
|---|---|
executor |
Executor: the Executor on which the callback will be invoked.
Must not be null. |
callback |
RangingSession.Callback: the RangingSession.Callback to handle session-related events.
Must not be null. |
| Returns | |
|---|---|
RangingSession |
the RangingSession instance if the session was successfully created,
or null if the session could not be created. |
| Throws | |
|---|---|
NullPointerException |
if callback or executor is null. |
SecurityException |
if the calling app does not have the necessary permissions to create a ranging session. |
registerCapabilitiesCallback
public void registerCapabilitiesCallback (Executor executor, RangingManager.RangingCapabilitiesCallback callback)
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. |
| Returns | |
|---|---|
void |
This value cannot be null. |
| Throws | |
|---|---|
NullPointerException |
if the executor or callback is null. |
unregisterCapabilitiesCallback
public void unregisterCapabilitiesCallback (RangingManager.RangingCapabilitiesCallback callback)
Unregisters a previously registered ranging capabilities callback.
| Parameters | |
|---|---|
callback |
RangingManager.RangingCapabilitiesCallback: The RangingCapabilitiesCallback to be unregistered.
Must not be null. |
| Returns | |
|---|---|
void |
This value cannot be null. |
| Throws | |
|---|---|
NullPointerException |
if the callback is null. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-09-17 UTC.