Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder for creating instances of RangingPreference
.
This Builder class provides a flexible way to construct a RangingPreference
instance by setting required and optional parameters. It ensures that all necessary parameters are specified and provides default values for optional configurations.
Example usage:
<code>RangingPreference rangingPreference = new RangingPreference.Builder(DEVICE_ROLE_RESPONDER,
new RawResponderRangingParams.Builder()
.setRawRangingDevice(
new RawRangingDevice.Builder()
.setRangingDevice(
new RangingDevice.Builder()
.build())
.setBleRssiRangingParams(
new BleRssiRangingParams.Builder("AA:BB:CC:00:11:22")
.build())
.build())
build())
.build();
</code>
Summary
Public constructors |
Creates a Builder instance with the required device role and RangingConfig .
|
Public constructors
Builder
Builder(
role: Int,
rangingConfig: RangingConfig)
Creates a Builder instance with the required device role and RangingConfig
.
Exceptions |
java.lang.NullPointerException |
if rangingConfig is null. |
Public methods
setSessionConfig
fun setSessionConfig(config: SessionConfig): RangingPreference.Builder
Sets the configuration parameters for the ranging session policy.
This method allows specifying additional configuration parameters encapsulated in SessionConfig
for fine-tuning the behavior of the ranging session.
Exceptions |
java.lang.NullPointerException |
if config 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-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[],null,["# RangingPreference.Builder\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/ranging/RangingPreference.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.ranging.RangingPreference.Builder](#) |\n\nBuilder for creating instances of `RangingPreference`.\n\nThis Builder class provides a flexible way to construct a [RangingPreference](/reference/kotlin/android/ranging/RangingPreference) instance by setting required and optional parameters. It ensures that all necessary parameters are specified and provides default values for optional configurations.\n\nExample usage: \n\n```kotlin\n\u003ccode\u003eRangingPreference rangingPreference = new RangingPreference.Builder(DEVICE_ROLE_RESPONDER,\n new RawResponderRangingParams.Builder()\n .setRawRangingDevice(\n new RawRangingDevice.Builder()\n .setRangingDevice(\n new RangingDevice.Builder()\n .build())\n .setBleRssiRangingParams(\n new BleRssiRangingParams.Builder(\"AA:BB:CC:00:11:22\")\n .build())\n .build())\n build())\n .build();\n \u003c/code\u003e\n```\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Builder](#Builder(kotlin.Int,%20android.ranging.RangingConfig))`(`role:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `rangingConfig:` `[RangingConfig](/reference/kotlin/android/ranging/RangingConfig)`)` Creates a Builder instance with the required device role and [RangingConfig](/reference/kotlin/android/ranging/RangingConfig). |\n\n| Public methods ||\n|--------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [RangingPreference](/reference/kotlin/android/ranging/RangingPreference) | [build](#build())`()` Builds the `RangingPreference` instance. |\n| [RangingPreference.Builder](#) | [setSessionConfig](#setSessionConfig(android.ranging.SessionConfig))`(`config:` `[SessionConfig](/reference/kotlin/android/ranging/SessionConfig)`)` Sets the configuration parameters for the ranging session policy. |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder(\n role: Int, \n rangingConfig: RangingConfig)\n```\n\nCreates a Builder instance with the required device role and [RangingConfig](/reference/kotlin/android/ranging/RangingConfig).\n\n| Parameters ||\n|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `role` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the role of the device in android.ranging.RangingPreference.DeviceRole Value is [android.ranging.RangingPreference#DEVICE_ROLE_RESPONDER](/reference/kotlin/android/ranging/RangingPreference#DEVICE_ROLE_RESPONDER:kotlin.Int), or [android.ranging.RangingPreference#DEVICE_ROLE_INITIATOR](/reference/kotlin/android/ranging/RangingPreference#DEVICE_ROLE_INITIATOR:kotlin.Int) |\n| `rangingConfig` | [RangingConfig](/reference/kotlin/android/ranging/RangingConfig): the [RangingConfig](/reference/kotlin/android/ranging/RangingConfig) to use. Needs to be an instance of one of the following: - [RawResponderRangingConfig](/reference/kotlin/android/ranging/raw/RawResponderRangingConfig) - [RawInitiatorRangingConfig](/reference/kotlin/android/ranging/raw/RawInitiatorRangingConfig) - [OobResponderRangingConfig](/reference/kotlin/android/ranging/oob/OobResponderRangingConfig) - [OobInitiatorRangingConfig](/reference/kotlin/android/ranging/oob/OobInitiatorRangingConfig) This value cannot be `null`. |\n\n| Exceptions ||\n|----------------------------------|-----------------------------|\n| `java.lang.NullPointerException` | if `rangingConfig` is null. |\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): RangingPreference\n```\n\nBuilds the `RangingPreference` instance.\n\nIf the [SessionConfig](/reference/kotlin/android/ranging/SessionConfig) is not set, default instances will be used.\n\n| Return ||\n|--------------------------------------------------------------------------|------------------------------------------------------------------|\n| [RangingPreference](/reference/kotlin/android/ranging/RangingPreference) | a new `RangingPreference` instance. This value cannot be `null`. |\n\n### setSessionConfig\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setSessionConfig(config: SessionConfig): RangingPreference.Builder\n```\n\nSets the configuration parameters for the ranging session policy.\n\nThis method allows specifying additional configuration parameters encapsulated in [SessionConfig](/reference/kotlin/android/ranging/SessionConfig) for fine-tuning the behavior of the ranging session.\n\n| Parameters ||\n|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `config` | [SessionConfig](/reference/kotlin/android/ranging/SessionConfig): the [SessionConfig](/reference/kotlin/android/ranging/SessionConfig). This value cannot be `null`. |\n\n| Return ||\n|--------------------------------|----------------------------------------------------------|\n| [RangingPreference.Builder](#) | this [Builder](#) instance. This value cannot be `null`. |\n\n| Exceptions ||\n|----------------------------------|----------------------|\n| `java.lang.NullPointerException` | if `config` is null. |"]]