# L2capNetworkSpecifier.Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 17](https://developer.android.com/sdkExtensions)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/L2capNetworkSpecifier.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                         ||
| ↳ | [android.net.L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) |

A builder class for L2capNetworkSpecifier.

## Summary

|                                                     Public constructors                                                     ||
|--------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                  Public methods                                                                                                                                                                                                                   ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [L2capNetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier)                  | [build](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#build())`()` Create the L2capNetworkSpecifier object.                                                                                                                                                                |
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | [setHeaderCompression](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#setHeaderCompression(kotlin.Int))`(`headerCompression:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the header compression mechanism to use for this network.  |
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | [setPsm](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#setPsm(kotlin.Int))`(`psm:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the Protocol/Service Multiplexer (PSM) for the client to connect to.                                 |
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | [setRemoteAddress](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#setRemoteAddress(android.net.MacAddress))`(`remoteAddress:` `[MacAddress](https://developer.android.com/reference/kotlin/android/net/MacAddress)?`)` Set the remote address for the client to connect to. |
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | [setRole](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#setRole(kotlin.Int))`(`role:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the role to use for this network.                                                                 |

## Public constructors

### Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 17](https://developer.android.com/sdkExtensions)  

```
Builder()
```

## Public methods

### build

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 17](https://developer.android.com/sdkExtensions)  

```
fun build(): L2capNetworkSpecifier
```

Create the L2capNetworkSpecifier object.

|                                                                 Return                                                                 ||
|-----------------------------------------------------------------------------------------------------------|-----------------------------|
| [L2capNetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier) | This value cannot be`null`. |

### setHeaderCompression

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 17](https://developer.android.com/sdkExtensions)  

```
fun setHeaderCompression(headerCompression: Int): L2capNetworkSpecifier.Builder
```

Set the header compression mechanism to use for this network. If not set, defaults to HEADER_COMPRESSION_ANY. This option must be specified (i.e. must not be set to HEADER_COMPRESSION_ANY) when requesting or reserving a new network.

|                                                                                                                                                                                                                                                                                                                                                 Parameters                                                                                                                                                                                                                                                                                                                                                 ||
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `headerCompression` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the header compression mechanism to use. Value is[android.net.L2capNetworkSpecifier#HEADER_COMPRESSION_ANY](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier#HEADER_COMPRESSION_ANY:kotlin.Int),[android.net.L2capNetworkSpecifier#HEADER_COMPRESSION_NONE](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier#HEADER_COMPRESSION_NONE:kotlin.Int), or[android.net.L2capNetworkSpecifier#HEADER_COMPRESSION_6LOWPAN](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier#HEADER_COMPRESSION_6LOWPAN:kotlin.Int) |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | This value cannot be`null`. |

### setPsm

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 17](https://developer.android.com/sdkExtensions)  

```
fun setPsm(psm: Int): L2capNetworkSpecifier.Builder
```

Set the Protocol/Service Multiplexer (PSM) for the client to connect to. If not set, defaults to PSM_ANY.

|                                                                                  Parameters                                                                                  ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `psm` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the Protocol/Service Multiplexer (PSM) to connect to. Value is between 0 and 255 inclusive |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | This value cannot be`null`. |

### setRemoteAddress

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 17](https://developer.android.com/sdkExtensions)  

```
fun setRemoteAddress(remoteAddress: MacAddress?): L2capNetworkSpecifier.Builder
```

Set the remote address for the client to connect to. Only valid for client networks. If not set, the specifier matches any MAC address.

|                                                                               Parameters                                                                               ||
|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `remoteAddress` | [MacAddress](https://developer.android.com/reference/kotlin/android/net/MacAddress)?:the MAC address to connect to, or null to match any MAC address. |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | This value cannot be`null`. |

### setRole

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 17](https://developer.android.com/sdkExtensions)  

```
fun setRole(role: Int): L2capNetworkSpecifier.Builder
```

Set the role to use for this network. If not set, defaults to ROLE_ANY.

|                                                                                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                                                                                      ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `role` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the role to use. Value is[android.net.L2capNetworkSpecifier#ROLE_ANY](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier#ROLE_ANY:kotlin.Int),[android.net.L2capNetworkSpecifier#ROLE_CLIENT](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier#ROLE_CLIENT:kotlin.Int), or[android.net.L2capNetworkSpecifier#ROLE_SERVER](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier#ROLE_SERVER:kotlin.Int) |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [L2capNetworkSpecifier.Builder](https://developer.android.com/reference/kotlin/android/net/L2capNetworkSpecifier.Builder#) | This value cannot be`null`. |