# AdvertisingSet

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#inhmethods)  

# AdvertisingSet

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSet "View this page in Kotlin")\|Java

`
public

final

class
AdvertisingSet
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.bluetooth.le.AdvertisingSet |

<br />

*** ** * ** ***

This class provides a way to control single Bluetooth LE advertising instance.

To get an instance of[AdvertisingSet](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet), call the[BluetoothLeAdvertiser.startAdvertisingSet(AdvertisingSetParameters, AdvertiseData, AdvertiseData, PeriodicAdvertisingParameters, AdvertiseData, AdvertisingSetCallback)](https://developer.android.com/reference/android/bluetooth/le/BluetoothLeAdvertiser#startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters,%20android.bluetooth.le.AdvertiseData,%20android.bluetooth.le.AdvertiseData,%20android.bluetooth.le.PeriodicAdvertisingParameters,%20android.bluetooth.le.AdvertiseData,%20android.bluetooth.le.AdvertisingSetCallback))method.  
**See also:**

- [AdvertiseData](https://developer.android.com/reference/android/bluetooth/le/AdvertiseData)

## Summary

|                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                           ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[enableAdvertising](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#enableAdvertising(boolean,%20int,%20int))`(boolean enable, int duration, int maxExtendedAdvertisingEvents) ` Enables Advertising.                                                                                                                                                                                                                          |
| ` void` | ` `[setAdvertisingData](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#setAdvertisingData(android.bluetooth.le.AdvertiseData))`(`[AdvertiseData](https://developer.android.com/reference/android/bluetooth/le/AdvertiseData)` advertiseData) ` Set/update data being Advertised.                                                                                                                                                 |
| ` void` | ` `[setAdvertisingParameters](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#setAdvertisingParameters(android.bluetooth.le.AdvertisingSetParameters))`(`[AdvertisingSetParameters](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSetParameters)` parameters) ` Update advertising parameters associated with this AdvertisingSet.                                                                      |
| ` void` | ` `[setPeriodicAdvertisingData](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#setPeriodicAdvertisingData(android.bluetooth.le.AdvertiseData))`(`[AdvertiseData](https://developer.android.com/reference/android/bluetooth/le/AdvertiseData)` periodicData) ` Used to set periodic advertising data, must be called after setPeriodicAdvertisingParameters, or after advertising was started with periodic advertising data set. |
| ` void` | ` `[setPeriodicAdvertisingEnabled](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#setPeriodicAdvertisingEnabled(boolean))`(boolean enable) ` Used to enable/disable periodic advertising.                                                                                                                                                                                                                                        |
| ` void` | ` `[setPeriodicAdvertisingParameters](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#setPeriodicAdvertisingParameters(android.bluetooth.le.PeriodicAdvertisingParameters))`(`[PeriodicAdvertisingParameters](https://developer.android.com/reference/android/bluetooth/le/PeriodicAdvertisingParameters)` parameters) ` Update periodic advertising parameters associated with this set.                                         |
| ` void` | ` `[setScanResponseData](https://developer.android.com/reference/android/bluetooth/le/AdvertisingSet#setScanResponseData(android.bluetooth.le.AdvertiseData))`(`[AdvertiseData](https://developer.android.com/reference/android/bluetooth/le/AdvertiseData)` scanResponse) ` Set/update scan response data.                                                                                                                                                   |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### enableAdvertising

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void enableAdvertising (boolean enable, 
                int duration, 
                int maxExtendedAdvertisingEvents)
```

Enables Advertising. This method returns immediately, the operation status is delivered through`callback.onAdvertisingEnabled()`.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH_ADMIN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)

<br />

|                                                                                                                     Parameters                                                                                                                      ||
|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `enable`                       | `boolean`: whether the advertising should be enabled (true), or disabled (false) <br />                                                                                                                             |
| `duration`                     | `int`: advertising duration, in 10ms unit. Valid range is from 1 (10ms) to 65535 (655,350 ms) <br />                                                                                                                |
| `maxExtendedAdvertisingEvents` | `int`: maximum number of extended advertising events the controller shall attempt to send prior to terminating the extended advertising, even if the duration has not expired. Valid range is from 1 to 255. <br /> |

### setAdvertisingData

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setAdvertisingData (AdvertiseData advertiseData)
```

Set/update data being Advertised. Make sure that data doesn't exceed the size limit for specified AdvertisingSetParameters. This method returns immediately, the operation status is delivered through`callback.onAdvertisingDataSet()`.

Advertising data must be empty if non-legacy scannable advertising is used.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH_ADMIN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)

<br />

|                                                                                                                                                                                                                         Parameters                                                                                                                                                                                                                          ||
|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `advertiseData` | `AdvertiseData`: Advertisement data to be broadcasted. Size must not exceed[BluetoothAdapter.getLeMaximumAdvertisingDataLength()](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getLeMaximumAdvertisingDataLength()). If the advertisement is connectable, three bytes will be added for flags. If the update takes place when the advertising set is enabled, the data can be maximum 251 bytes long. <br /> |

### setAdvertisingParameters

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setAdvertisingParameters (AdvertisingSetParameters parameters)
```

Update advertising parameters associated with this AdvertisingSet. Must be called when advertising is not active. This method returns immediately, the operation status is delivered through`callback.onAdvertisingParametersUpdated`.

Requires the[Manifest.permission.BLUETOOTH_PRIVILEGED](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED)permission when`parameters.getOwnAddressType()`is different from`AdvertisingSetParameters.ADDRESS_TYPE_DEFAULT`or`parameters.isDirected()`is true.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH_ADMIN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).

<br />

|                                  Parameters                                  ||
|--------------|----------------------------------------------------------------|
| `parameters` | `AdvertisingSetParameters`: advertising set parameters. <br /> |

### setPeriodicAdvertisingData

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setPeriodicAdvertisingData (AdvertiseData periodicData)
```

Used to set periodic advertising data, must be called after setPeriodicAdvertisingParameters, or after advertising was started with periodic advertising data set. This method returns immediately, the operation status is delivered through`callback.onPeriodicAdvertisingDataSet()`.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH_ADMIN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)

<br />

|                                                                                                                                                                                       Parameters                                                                                                                                                                                        ||
|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `periodicData` | `AdvertiseData`: Periodic advertising data. Size must not exceed[BluetoothAdapter.getLeMaximumAdvertisingDataLength()](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getLeMaximumAdvertisingDataLength()). If the update takes place when the periodic advertising is enabled for this set, the data can be maximum 251 bytes long. <br /> |

### setPeriodicAdvertisingEnabled

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setPeriodicAdvertisingEnabled (boolean enable)
```

Used to enable/disable periodic advertising. This method returns immediately, the operation status is delivered through`callback.onPeriodicAdvertisingEnable()`.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH_ADMIN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)

<br />

|                                                 Parameters                                                  ||
|----------|---------------------------------------------------------------------------------------------------|
| `enable` | `boolean`: whether the periodic advertising should be enabled (true), or disabled (false). <br /> |

### setPeriodicAdvertisingParameters

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setPeriodicAdvertisingParameters (PeriodicAdvertisingParameters parameters)
```

Update periodic advertising parameters associated with this set. Must be called when periodic advertising is not enabled. This method returns immediately, the operation status is delivered through`callback.onPeriodicAdvertisingParametersUpdated()`.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH_ADMIN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)

<br />

|                      Parameters                      ||
|--------------|----------------------------------------|
| `parameters` | `PeriodicAdvertisingParameters` <br /> |

### setScanResponseData

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setScanResponseData (AdvertiseData scanResponse)
```

Set/update scan response data. Make sure that data doesn't exceed the size limit for specified AdvertisingSetParameters. This method returns immediately, the operation status is delivered through`callback.onScanResponseDataSet()`.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH_ADMIN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE)

<br />

|                                                                                                                                                                                           Parameters                                                                                                                                                                                           ||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `scanResponse` | `AdvertiseData`: Scan response associated with the advertisement data. Size must not exceed[BluetoothAdapter.getLeMaximumAdvertisingDataLength](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getLeMaximumAdvertisingDataLength()). If the update takes place when the advertising set is enabled, the data can be maximum 251 bytes long. <br /> |