Added in API level 28

android.net.wifi.rtt

Provides classes which allow applications to use Wi-Fi RTT (IEEE 802.11mc) to measure distance to supporting Access Points and peer devices.

The primary entry point to Wi-Fi RTT capabilities is the WifiRttManager class, which is acquired by calling Context.getSystemService(Context.WIFI_RTT_RANGING_SERVICE)

Some APIs may require the following user permissions:

Usage of the API is also gated by the device's Location Mode: whether it permits Wi-Fi based location to be queried.

Note: Not all Android-powered devices support Wi-Fi RTT functionality. If your application only works with Wi-Fi RTT (i.e. it should only be installed on devices which support Wi-Fi RTT), declare so with a <uses-feature> element in the manifest file:

 <manifest ...>
     <uses-feature android:name="android.hardware.wifi.rtt" />
     ...
 </manifest>
 

Alternatively, if your application does not require Wi-Fi RTT but can take advantage of it if available, you can perform the check at run-time in your code using hasSystemFeature(String) with FEATURE_WIFI_RTT:

     getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_RTT)
 

For an example of this functionality, see Wi-Fi location: ranging with RTT.

Classes

CivicLocationKeys Civic Address key types used to define address elements. 
RangingRequest Defines the ranging request to other devices. 
RangingRequest.Builder Builder class used to construct RangingRequest objects. 
RangingResult Ranging result for a request started by WifiRttManager#startRanging(RangingRequest, java.util.concurrent.Executor, RangingResultCallback)
RangingResultCallback Base class for ranging result callbacks. 
ResponderConfig Defines the configuration of an IEEE 802.11mc Responder. 
ResponderConfig.Builder Builder class used to construct ResponderConfig objects. 
ResponderLocation ResponderLocation is both a Location Configuration Information (LCI) decoder and a Location Civic Report (LCR) decoder for information received from a Wi-Fi Access Point (AP) during Wi-Fi RTT ranging process. 
WifiRttManager This class provides the primary API for measuring distance (range) to other devices using the IEEE 802.11mc Wi-Fi Round Trip Time (RTT) technology.