Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#nestedclasses) \| [Constants](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#constants) \| [Methods](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#inhmethods)

# BluetoothAdapter

*** ** * ** ***


`
public

final

class
BluetoothAdapter
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

Represents the local device Bluetooth adapter. The `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter` lets you perform
fundamental Bluetooth tasks, such as initiate device discovery, query a list of bonded (paired)
devices, instantiate a `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` using a known MAC address, and create a `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` to listen for connection requests from other devices, and start a scan for
Bluetooth LE devices.

To get a `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter` representing the local Bluetooth adapter, call the `https://developer.android.com/reference/android/bluetooth/BluetoothManager#getAdapter()` function on `https://developer.android.com/reference/android/bluetooth/BluetoothManager`. On JELLY_BEAN_MR1 and below
you will need to use the static `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getDefaultAdapter()` method instead.

Fundamentally, this is your starting point for all Bluetooth actions. Once you have the local
adapter, you can get a set of `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` objects representing all paired devices
with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()`; start device discovery with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#startDiscovery()`; or
create a `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` to listen for incoming RFComm connection requests with
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingRfcommWithServiceRecord(java.lang.String,%20java.util.UUID)`; listen for incoming L2CAP
Connection-oriented Channels (CoC) connection requests with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel()`;
or start a scan for Bluetooth LE devices with `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(android.bluetooth.le.ScanCallback)`
using the scanner from `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBluetoothLeScanner()`.

This class is thread safe.

### Developer Guides

For more information about using Bluetooth, read the [Bluetooth](https://developer.android.com/guide/topics/connectivity/bluetooth) developer guide.

<br />

**See also:**

- `https://developer.android.com/reference/android/bluetooth/BluetoothDevice`
- `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket`

## Summary

| ### Nested classes ||
|---|---|
| ` interface` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback` Callback interface used to deliver LE scan results. |

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_CONNECTION_STATE_CHANGED` Intent used to broadcast the change in connection state of the local Bluetooth adapter to a profile of the remote device. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_DISCOVERY_FINISHED` Broadcast Action: The local Bluetooth adapter has finished the device discovery process. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_DISCOVERY_STARTED` Broadcast Action: The local Bluetooth adapter has started the remote device discovery process. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_LOCAL_NAME_CHANGED` Broadcast Action: The local Bluetooth adapter has changed its friendly Bluetooth name. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_DISCOVERABLE` Activity Action: Show a system activity that requests discoverable mode. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE` Activity Action: Show a system activity that allows the user to turn on Bluetooth. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_SCAN_MODE_CHANGED` Broadcast Action: Indicates the Bluetooth scan mode of the local Adapter has changed. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` Broadcast Action: The state of the local Bluetooth adapter has been changed. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ERROR` Sentinel error value for this class. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_CONNECTION_STATE` Extra used by `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_CONNECTION_STATE_CHANGED` This extra represents the current connection state. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_DISCOVERABLE_DURATION` Used as an optional int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_DISCOVERABLE` intents to request a specific duration for discoverability in seconds. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_LOCAL_NAME` Used as a String extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_LOCAL_NAME_CHANGED` intents to request the local Bluetooth name. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_PREVIOUS_CONNECTION_STATE` Extra used by `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_CONNECTION_STATE_CHANGED` This extra represents the previous connection state. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_PREVIOUS_SCAN_MODE` Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_SCAN_MODE_CHANGED` intents to request the previous scan mode. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_PREVIOUS_STATE` Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` intents to request the previous power state. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_SCAN_MODE` Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_SCAN_MODE_CHANGED` intents to request the current scan mode. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_STATE` Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` intents to request the current power state. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE` Indicates that inquiry scan is disabled, but page scan is enabled on the local Bluetooth adapter. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE` Indicates that both inquiry scan and page scan are enabled on the local Bluetooth adapter. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_NONE` Indicates that both inquiry scan and page scan are disabled on the local Bluetooth adapter. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_CONNECTED` The profile is in connected state |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_CONNECTING` The profile is in connecting state |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_DISCONNECTED` The profile is in disconnected state |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_DISCONNECTING` The profile is in disconnecting state |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF` Indicates the local Bluetooth adapter is off. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` Indicates the local Bluetooth adapter is on, and ready for use. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_OFF` Indicates the local Bluetooth adapter is turning off. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_ON` Indicates the local Bluetooth adapter is turning on. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#cancelDiscovery()() ` Cancel the current device discovery process. |
| ` static boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#checkBluetoothAddress(java.lang.String)(https://developer.android.com/reference/java/lang/String address) ` Validate a String Bluetooth address, such as "00:43:A8:23:10:F0" Alphabetic characters must be uppercase to be valid. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#closeProfileProxy(int,%20android.bluetooth.BluetoothProfile)(int unusedProfile, https://developer.android.com/reference/android/bluetooth/BluetoothProfile proxy) ` Close the connection of the profile proxy to the Service. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()() ` *This method was deprecated in API level 33. Starting with `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, applications are not allowed to enable/disable Bluetooth. **Compatibility Note:** For applications targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU` or above, this API will always fail and return `false`. If apps are targeting an older SDK (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or below), they can continue to use this API.* *Deprecation Exemptions:* *- Device Owner (DO), Profile Owner (PO) and system apps.* <br /> |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()() ` *This method was deprecated in API level 33. Starting with `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, applications are not allowed to enable/disable Bluetooth. **Compatibility Note:** For applications targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU` or above, this API will always fail and return `false`. If apps are targeting an older SDK (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or below), they can continue to use this API.* *Deprecation Exemptions:* *- Device Owner (DO), Profile Owner (PO) and system apps.* <br /> |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getAddress()() ` Returns the hardware address of the local Bluetooth adapter. |
| ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeAdvertiser` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBluetoothLeAdvertiser()() ` Returns a `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeAdvertiser` object for Bluetooth LE Advertising operations. |
| ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBluetoothLeScanner()() ` Returns a `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner` object for Bluetooth LE scan operations. |
| ` https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()() ` Return the set of `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` objects that are bonded (paired) to the local adapter. |
| ` static https://developer.android.com/reference/android/bluetooth/BluetoothAdapter` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getDefaultAdapter()() ` *This method was deprecated in API level 31. Use `context.getSystemService(BluetoothManager.class).getAdapter()` instead to allows context override such as `https://developer.android.com/reference/android/content/Context#createAttributionContext(java.lang.String)` or `https://developer.android.com/`.* |
| ` https://developer.android.com/reference/java/time/Duration` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getDiscoverableTimeout()() ` Get the timeout duration of the `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE`. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getLeMaximumAdvertisingDataLength()() ` Return the maximum LE advertising data length in bytes, if LE Extended Advertising feature is supported, 0 otherwise. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getMaxConnectedAudioDevices()() ` Get the maximum number of connected devices per audio profile for this device. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getName()() ` Get the friendly Bluetooth name of the local Bluetooth adapter. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getProfileConnectionState(int)(int profile) ` Get the current connection state of a profile. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getProfileProxy(android.content.Context,%20android.bluetooth.BluetoothProfile.ServiceListener,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/bluetooth/BluetoothProfile.ServiceListener listener, int profile) ` Get the profile proxy object associated with the profile. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothDevice` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getRemoteDevice(byte[])(byte[] address) ` Get a `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` object for the given Bluetooth hardware address. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothDevice` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getRemoteDevice(java.lang.String)(https://developer.android.com/reference/java/lang/String address) ` Get a `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` object for the given Bluetooth hardware address. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothDevice` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getRemoteLeDevice(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String address, int addressType) ` Get a `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` object for the given Bluetooth hardware address and addressType. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getScanMode()() ` Get the current Bluetooth scan mode of the local Bluetooth adapter. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getState()() ` Get the current state of the local Bluetooth adapter. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isDiscovering()() ` Return true if the local Bluetooth adapter is currently in the device discovery process. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isEnabled()() ` Return true if Bluetooth is currently enabled and ready for use. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLe2MPhySupported()() ` Return true if LE 2M PHY feature is supported. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLeAudioBroadcastAssistantSupported()() ` Returns `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` if the LE audio broadcast assistant feature is supported, `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` if the feature is not supported, or an error code. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLeAudioBroadcastSourceSupported()() ` Returns `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` if the LE audio broadcast source feature is supported, `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` if the feature is not supported, or an error code. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLeAudioSupported()() ` Returns `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` if the LE audio feature is supported, `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` if the feature is not supported, or an error code. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLeCodedPhySupported()() ` Return true if LE Coded PHY feature is supported. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLeExtendedAdvertisingSupported()() ` Return true if LE Extended Advertising feature is supported. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLeHighDataThroughputPhySupported()() ` Checks if LE High Data Throughput (HDT) PHY is supported. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isLePeriodicAdvertisingSupported()() ` Return true if LE Periodic Advertising feature is supported. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isMultipleAdvertisementSupported()() ` Return true if the multi advertisement is supported by the chipset. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isOffloadedFilteringSupported()() ` Return true if offloaded filters are supported. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isOffloadedScanBatchingSupported()() ` Return true if offloaded scan batching is supported. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingInsecureL2capChannel()() ` Create an insecure L2CAP Connection-oriented Channel (CoC) `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` and assign a dynamic PSM value. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingInsecureRfcommWithServiceRecord(java.lang.String,%20java.util.UUID)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/util/UUID uuid) ` Create a listening, insecure RFCOMM Bluetooth socket with Service Record. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel()() ` Create a secure L2CAP Connection-oriented Channel (CoC) `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` and assign a dynamic protocol/service multiplexer (PSM) value. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingRfcommWithServiceRecord(java.lang.String,%20java.util.UUID)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/util/UUID uuid) ` Create a listening, secure RFCOMM Bluetooth socket with Service Record. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingSocketSettings(android.bluetooth.BluetoothSocketSettings)(https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings settings) ` Creates a listening server channel for Bluetooth connections with the specified socket settings `https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings`. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#setName(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Set the friendly Bluetooth name of the local Bluetooth adapter. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#startDiscovery()() ` Start the remote device discovery process. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#startLeScan(java.util.UUID[],%20android.bluetooth.BluetoothAdapter.LeScanCallback)(https://developer.android.com/reference/java/util/UUID serviceUuids, https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback callback) ` *This method was deprecated in API level 21. use `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.bluetooth.le.ScanCallback)` instead.* |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#startLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback)(https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback callback) ` *This method was deprecated in API level 21. use `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.bluetooth.le.ScanCallback)` instead.* |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#stopLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback)(https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback callback) ` *This method was deprecated in API level 21. Use `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#stopScan(android.bluetooth.le.ScanCallback)` instead.* |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
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

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
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` `
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` `
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*.


## Constants

### ACTION_CONNECTION_STATE_CHANGED

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

```
public static final String ACTION_CONNECTION_STATE_CHANGED
```

Intent used to broadcast the change in connection state of the local Bluetooth adapter to a
profile of the remote device. When the adapter is not connected to any profiles of any remote
devices and it attempts a connection to a profile this intent will be sent. Once connected,
this intent will not be sent for any more connection attempts to any profiles of any remote
device. When the adapter disconnects from the last profile its connected to of any remote
device, this intent will be sent.

This intent is useful for applications that are only concerned about whether the local
adapter is connected to any profile of any device and are not really concerned about which
profile. For example, an application which displays an icon to display whether Bluetooth is
connected or not can use this intent.

This intent will have 3 extras: `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_CONNECTION_STATE` - The current connection
state. `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_PREVIOUS_CONNECTION_STATE`- The previous connection state. `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#EXTRA_DEVICE` - The remote device.

`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_CONNECTION_STATE` or `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_PREVIOUS_CONNECTION_STATE` can be any of
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_DISCONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_CONNECTING`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_CONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_DISCONNECTING`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

Constant Value:

"android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED"


### ACTION_DISCOVERY_FINISHED

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

```
public static final String ACTION_DISCOVERY_FINISHED
```

Broadcast Action: The local Bluetooth adapter has finished the device discovery process.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

Constant Value:

"android.bluetooth.adapter.action.DISCOVERY_FINISHED"


### ACTION_DISCOVERY_STARTED

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

```
public static final String ACTION_DISCOVERY_STARTED
```

Broadcast Action: The local Bluetooth adapter has started the remote device discovery
process.

This usually involves an inquiry scan of about 12 seconds, followed by a page scan of each
new device to retrieve its Bluetooth name.

Register for `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ACTION_FOUND` to be notified as remote Bluetooth
devices are found.

Device discovery is a heavyweight procedure. New connections to remote Bluetooth devices
should not be attempted while discovery is in progress, and existing connections will
experience limited bandwidth and high latency. Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#cancelDiscovery()` to cancel an
ongoing discovery.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

Constant Value:

"android.bluetooth.adapter.action.DISCOVERY_STARTED"


### ACTION_LOCAL_NAME_CHANGED

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

```
public static final String ACTION_LOCAL_NAME_CHANGED
```

Broadcast Action: The local Bluetooth adapter has changed its friendly Bluetooth name.

This name is visible to remote Bluetooth devices.

Always contains the extra field `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_LOCAL_NAME` containing the name.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

Constant Value:

"android.bluetooth.adapter.action.LOCAL_NAME_CHANGED"


### ACTION_REQUEST_DISCOVERABLE

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

```
public static final String ACTION_REQUEST_DISCOVERABLE
```

Activity Action: Show a system activity that requests discoverable mode. This activity will
also request the user to turn on Bluetooth if it is not currently enabled.

Discoverable mode is equivalent to `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE`. It allows
remote devices to see this Bluetooth adapter when they perform a discovery.

For privacy, Android is not discoverable by default.

The sender of this Intent can optionally use extra field `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_DISCOVERABLE_DURATION` to request the duration of discoverability. Currently the
default duration is 120 seconds, and maximum duration is capped at 300 seconds for each
request.

Notification of the result of this activity is posted using the `https://developer.android.com/reference/android/app/Activity#onActivityResult(int,%20int,%20android.content.Intent)` callback. The `resultCode` will be the
duration (in seconds) of discoverability or `https://developer.android.com/reference/android/app/Activity#RESULT_CANCELED` if
the user rejected discoverability or an error has occurred.

Applications can also listen for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_SCAN_MODE_CHANGED` for global notification
whenever the scan mode changes. For example, an application can be notified when the device
has ended discoverability.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE`

<br />

Constant Value:

"android.bluetooth.adapter.action.REQUEST_DISCOVERABLE"


### ACTION_REQUEST_ENABLE

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

```
public static final String ACTION_REQUEST_ENABLE
```

Activity Action: Show a system activity that allows the user to turn on Bluetooth.

This system activity will return once Bluetooth has completed turning on, or the user has
decided not to turn Bluetooth on.

Notification of the result of this activity is posted using the `https://developer.android.com/reference/android/app/Activity#onActivityResult(int,%20int,%20android.content.Intent)` callback. The `resultCode` will be `https://developer.android.com/reference/android/app/Activity#RESULT_OK` if Bluetooth has been turned on or `https://developer.android.com/reference/android/app/Activity#RESULT_CANCELED` if the user has rejected the request or an error has
occurred.

Applications can also listen for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` for global notification
whenever Bluetooth is turned on or off.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

Constant Value:

"android.bluetooth.adapter.action.REQUEST_ENABLE"


### ACTION_SCAN_MODE_CHANGED

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

```
public static final String ACTION_SCAN_MODE_CHANGED
```

Broadcast Action: Indicates the Bluetooth scan mode of the local Adapter has changed.

Always contains the extra fields `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_SCAN_MODE` and `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_PREVIOUS_SCAN_MODE` containing the new and old scan modes respectively.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

Constant Value:

"android.bluetooth.adapter.action.SCAN_MODE_CHANGED"


### ACTION_STATE_CHANGED

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

```
public static final String ACTION_STATE_CHANGED
```

Broadcast Action: The state of the local Bluetooth adapter has been changed.

For example, Bluetooth has been turned on or off.

Always contains the extra fields `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_STATE` and `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_PREVIOUS_STATE`
containing the new and old states respectively.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

Constant Value:

"android.bluetooth.adapter.action.STATE_CHANGED"


### ERROR

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

```
public static final int ERROR
```

Sentinel error value for this class. Guaranteed to not equal any other integer constant in
this class. Provided as a convenience for functions that require a sentinel error value, for
example:

`Intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
BluetoothAdapter.ERROR)`

<br />

Constant Value:

-2147483648
(0x80000000)


### EXTRA_CONNECTION_STATE

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

```
public static final String EXTRA_CONNECTION_STATE
```

Extra used by `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_CONNECTION_STATE_CHANGED`

This extra represents the current connection state.

<br />

Constant Value:

"android.bluetooth.adapter.extra.CONNECTION_STATE"


### EXTRA_DISCOVERABLE_DURATION

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

```
public static final String EXTRA_DISCOVERABLE_DURATION
```

Used as an optional int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_DISCOVERABLE` intents to
request a specific duration for discoverability in seconds. The current default is 120
seconds, and requests over 300 seconds will be capped. These values could change.

<br />

Constant Value:

"android.bluetooth.adapter.extra.DISCOVERABLE_DURATION"


### EXTRA_LOCAL_NAME

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

```
public static final String EXTRA_LOCAL_NAME
```

Used as a String extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_LOCAL_NAME_CHANGED` intents to request the
local Bluetooth name.

<br />

Constant Value:

"android.bluetooth.adapter.extra.LOCAL_NAME"


### EXTRA_PREVIOUS_CONNECTION_STATE

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

```
public static final String EXTRA_PREVIOUS_CONNECTION_STATE
```

Extra used by `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_CONNECTION_STATE_CHANGED`

This extra represents the previous connection state.

<br />

Constant Value:

"android.bluetooth.adapter.extra.PREVIOUS_CONNECTION_STATE"


### EXTRA_PREVIOUS_SCAN_MODE

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

```
public static final String EXTRA_PREVIOUS_SCAN_MODE
```

Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_SCAN_MODE_CHANGED` intents to request the
previous scan mode. Possible values are: `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_NONE`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE`,

<br />

Constant Value:

"android.bluetooth.adapter.extra.PREVIOUS_SCAN_MODE"


### EXTRA_PREVIOUS_STATE

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

```
public static final String EXTRA_PREVIOUS_STATE
```

Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` intents to request the previous
power state. Possible values are: `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_ON`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_OFF`

<br />

Constant Value:

"android.bluetooth.adapter.extra.PREVIOUS_STATE"


### EXTRA_SCAN_MODE

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

```
public static final String EXTRA_SCAN_MODE
```

Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_SCAN_MODE_CHANGED` intents to request the
current scan mode. Possible values are: `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_NONE`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE`,

<br />

Constant Value:

"android.bluetooth.adapter.extra.SCAN_MODE"


### EXTRA_STATE

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

```
public static final String EXTRA_STATE
```

Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` intents to request the current
power state. Possible values are: `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_ON`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_OFF`,

<br />

Constant Value:

"android.bluetooth.adapter.extra.STATE"


### SCAN_MODE_CONNECTABLE

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

```
public static final int SCAN_MODE_CONNECTABLE
```

Indicates that inquiry scan is disabled, but page scan is enabled on the local Bluetooth
adapter. Therefore this device is not discoverable from remote Bluetooth devices, but is
connectable from remote devices that have previously discovered this device.

<br />

Constant Value:

21
(0x00000015)


### SCAN_MODE_CONNECTABLE_DISCOVERABLE

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

```
public static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE
```

Indicates that both inquiry scan and page scan are enabled on the local Bluetooth adapter.
Therefore this device is both discoverable and connectable from remote Bluetooth devices.

<br />

Constant Value:

23
(0x00000017)


### SCAN_MODE_NONE

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

```
public static final int SCAN_MODE_NONE
```

Indicates that both inquiry scan and page scan are disabled on the local Bluetooth adapter.
Therefore this device is neither discoverable nor connectable from remote Bluetooth devices.

<br />

Constant Value:

20
(0x00000014)


### STATE_CONNECTED

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

```
public static final int STATE_CONNECTED
```

The profile is in connected state

<br />

Constant Value:

2
(0x00000002)


### STATE_CONNECTING

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

```
public static final int STATE_CONNECTING
```

The profile is in connecting state

<br />

Constant Value:

1
(0x00000001)


### STATE_DISCONNECTED

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

```
public static final int STATE_DISCONNECTED
```

The profile is in disconnected state

<br />

Constant Value:

0
(0x00000000)


### STATE_DISCONNECTING

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

```
public static final int STATE_DISCONNECTING
```

The profile is in disconnecting state

<br />

Constant Value:

3
(0x00000003)


### STATE_OFF

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

```
public static final int STATE_OFF
```

Indicates the local Bluetooth adapter is off.

<br />

Constant Value:

10
(0x0000000a)


### STATE_ON

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

```
public static final int STATE_ON
```

Indicates the local Bluetooth adapter is on, and ready for use.

<br />

Constant Value:

12
(0x0000000c)


### STATE_TURNING_OFF

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

```
public static final int STATE_TURNING_OFF
```

Indicates the local Bluetooth adapter is turning off. Local clients should immediately
attempt graceful disconnection of any remote links.

<br />

Constant Value:

13
(0x0000000d)


### STATE_TURNING_ON

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

```
public static final int STATE_TURNING_ON
```

Indicates the local Bluetooth adapter is turning on. However local clients should wait for
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` before attempting to use the adapter.

<br />

Constant Value:

11
(0x0000000b)


## Public methods

### cancelDiscovery

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

```
public boolean cancelDiscovery ()
```

Cancel the current device discovery process.

Because discovery is a heavyweight procedure for the Bluetooth adapter, this method should
always be called before attempting to connect to a remote device with `https://developer.android.com/reference/android/bluetooth/BluetoothSocket#connect()`. Discovery is not managed by the Activity, but
is run as a system service, so an application should always call cancel discovery even if it
did not directly request a discovery, just to be sure.

If Bluetooth state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, this API will return false. After turning on
Bluetooth, wait for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` to get the updated
value.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Returns ||
|---|---|
| `boolean` | true on success, false on error <br /> |

### checkBluetoothAddress

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

```
public static boolean checkBluetoothAddress (String address)
```

Validate a String Bluetooth address, such as "00:43:A8:23:10:F0"

Alphabetic characters must be uppercase to be valid.

<br />

| Parameters ||
|---|---|
| `address` | `String`: Bluetooth address as string <br /> |

| Returns ||
|---|---|
| `boolean` | true if the address is valid, false otherwise <br /> |

### closeProfileProxy

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

```
public void closeProfileProxy (int unusedProfile, 
                BluetoothProfile proxy)
```

Close the connection of the profile proxy to the Service.

Clients should call this when they are no longer using the proxy obtained from `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getProfileProxy(android.content.Context,%20android.bluetooth.BluetoothProfile.ServiceListener,%20int)`. Profile can be one of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEADSET` or `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#A2DP`

<br />

| Parameters ||
|---|---|
| `unusedProfile` | `int` <br /> |
| `proxy` | `BluetoothProfile`: Profile proxy object <br /> |

### disable

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

```
public boolean disable ()
```


**This method was deprecated
in API level 33.**   

Starting with `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, applications are
not allowed to enable/disable Bluetooth. **Compatibility Note:** For applications
targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU` or above, this API will always
fail and return `false`. If apps are targeting an older SDK (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or below), they can continue to use this API.

Deprecation Exemptions:

- Device Owner (DO), Profile Owner (PO) and system apps.

<br />

Turn off the local Bluetooth adapter---do not use without explicit user action to turn
off Bluetooth.

This gracefully shuts down all Bluetooth connections, stops Bluetooth system services, and
powers down the underlying Bluetooth hardware.

**Bluetooth should never be disabled without direct user
consent** . The `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()` method is provided only for applications that
include a user interface for changing system settings, such as a "power manager" app.

This is an asynchronous call: it will return immediately, and clients should listen for
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` to be notified of subsequent adapter state changes. If this
call returns true, then the adapter state will immediately transition from `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`
to `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_OFF`, and some time later transition to either `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF` or
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`. If this call returns false then there was an immediate problem that will
prevent the adapter from being turned off - such as the adapter already being turned off.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `boolean` | true to indicate adapter shutdown has begun, or false on immediate error <br /> |

### enable

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

```
public boolean enable ()
```


**This method was deprecated
in API level 33.**   

Starting with `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, applications are
not allowed to enable/disable Bluetooth. **Compatibility Note:** For applications
targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU` or above, this API will always
fail and return `false`. If apps are targeting an older SDK (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or below), they can continue to use this API.

Deprecation Exemptions:

- Device Owner (DO), Profile Owner (PO) and system apps.

<br />

Turn on the local Bluetooth adapter---do not use without explicit user action to turn on
Bluetooth.

This powers on the underlying Bluetooth hardware, and starts all Bluetooth system
services.

**Bluetooth should never be enabled without direct user
consent** . If you want to turn on Bluetooth in order to create a wireless connection,
you should use the `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE` Intent, which will raise a dialog that
requests user permission to turn on Bluetooth. The `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()` method is provided only
for applications that include a user interface for changing system settings, such as a "power
manager" app.

This is an asynchronous call: it will return immediately, and clients should listen for
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` to be notified of subsequent adapter state changes. If this
call returns true, then the adapter state will immediately transition from `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF`
to `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_ON`, and some time later transition to either `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF` or
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`. If this call returns false then there was an immediate problem that will
prevent the adapter from being turned on - such as Airplane mode, or the adapter is already
turned on.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `boolean` | true to indicate adapter startup has begun, or false on immediate error <br /> |

### getAddress

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

```
public String getAddress ()
```

Returns the hardware address of the local Bluetooth adapter.

For example, "00:11:22:AA:BB:CC".


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` and `https://developer.android.com/`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | Bluetooth hardware address as string <br /> |

### getBluetoothLeAdvertiser

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

```
public BluetoothLeAdvertiser getBluetoothLeAdvertiser ()
```

Returns a `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeAdvertiser` object for Bluetooth LE Advertising operations. Will
return null if Bluetooth is turned off or if Bluetooth LE Advertising is not supported on
this device.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isEnabled()` to check if Bluetooth is currently enabled. Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isMultipleAdvertisementSupported()` to check whether LE Advertising is supported on this
device before calling this method.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeAdvertiser` | <br /> |

### getBluetoothLeScanner

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

```
public BluetoothLeScanner getBluetoothLeScanner ()
```

Returns a `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner` object for Bluetooth LE scan operations. Will return
null if Bluetooth is turned off.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isEnabled()` to check if Bluetooth is currently enabled.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner` | <br /> |

### getBondedDevices

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

```
public Set<BluetoothDevice> getBondedDevices ()
```

Return the set of `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` objects that are bonded (paired) to the local
adapter.

If Bluetooth state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, this API will return an empty set. After
turning on Bluetooth, wait for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` to get
the updated value.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` | unmodifiable set of `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` <br /> |

### getDefaultAdapter

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

```
public static BluetoothAdapter getDefaultAdapter ()
```


**This method was deprecated
in API level 31.**   

Use `context.getSystemService(BluetoothManager.class).getAdapter()` instead
to allows context override such as `https://developer.android.com/reference/android/content/Context#createAttributionContext(java.lang.String)` or `https://developer.android.com/`.

Get a handle to the default local Bluetooth adapter.

Currently Android only supports one Bluetooth adapter, but the API could be extended to
support more. This will always return the default adapter.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter` | the default local adapter, or null if Bluetooth is not supported on this hardware platform <br /> |

### getDiscoverableTimeout

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

```
public Duration getDiscoverableTimeout ()
```

Get the timeout duration of the `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/Duration` | the duration of the discoverable timeout or null if an error has occurred <br /> |

### getLeMaximumAdvertisingDataLength

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

```
public int getLeMaximumAdvertisingDataLength ()
```

Return the maximum LE advertising data length in bytes, if LE Extended Advertising feature is
supported, 0 otherwise.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `int` | the maximum LE advertising data length. <br /> |

### getMaxConnectedAudioDevices

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

```
public int getMaxConnectedAudioDevices ()
```

Get the maximum number of connected devices per audio profile for this device.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `int` | the number of allowed simultaneous connected devices for each audio profile for this device, or -1 if the Bluetooth service can't be reached <br /> |

### getName

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

```
public String getName ()
```

Get the friendly Bluetooth name of the local Bluetooth adapter.

This name is visible to remote Bluetooth devices.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the Bluetooth name, or null on error <br /> |

### getProfileConnectionState

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

```
public int getProfileConnectionState (int profile)
```

Get the current connection state of a profile. This function can be used to check whether the
local Bluetooth adapter is connected to any remote device for a specific profile. Profile can
be one of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEADSET`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#A2DP`.

Return the profile connection state.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `profile` | `int` <br /> |

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_DISCONNECTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_CONNECTING` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_CONNECTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_DISCONNECTING` |

### getProfileProxy

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

```
public boolean getProfileProxy (Context context, 
                BluetoothProfile.ServiceListener listener, 
                int profile)
```

Get the profile proxy object associated with the profile.

The ServiceListener's methods will be invoked on the application's main looper

<br />

| Parameters ||
|---|---|
| `context` | `Context`: Context of the application <br /> |
| `listener` | `BluetoothProfile.ServiceListener`: The service listener for connection callbacks. <br /> |
| `profile` | `int`: The Bluetooth profile to listen for status change <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false on error <br /> |

### getRemoteDevice

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

```
public BluetoothDevice getRemoteDevice (byte[] address)
```

Get a `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` object for the given Bluetooth hardware address.

Valid Bluetooth hardware addresses must be 6 bytes. This method expects the address in
network byte order (MSB first).

A `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` will always be returned for a valid hardware address, even if
this adapter has never seen that device.

<br />

| Parameters ||
|---|---|
| `address` | `byte`: Bluetooth MAC address (6 bytes) <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if address is invalid |

### getRemoteDevice

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

```
public BluetoothDevice getRemoteDevice (String address)
```

Get a `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` object for the given Bluetooth hardware address.

Valid Bluetooth hardware addresses must be upper case, in big endian byte order, and in a
format such as "00:11:22:33:AA:BB". The helper `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#checkBluetoothAddress(java.lang.String)` is available to
validate a Bluetooth address.

A `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` will always be returned for a valid hardware address, even if
this adapter has never seen that device.

<br />

| Parameters ||
|---|---|
| `address` | `String`: valid Bluetooth MAC address <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if address is invalid |

### getRemoteLeDevice

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

```
public BluetoothDevice getRemoteLeDevice (String address, 
                int addressType)
```

Get a `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` object for the given Bluetooth hardware address and
addressType.

Valid Bluetooth hardware addresses must be upper case, in big endian byte order, and in a
format such as "00:11:22:33:AA:BB". The helper `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#checkBluetoothAddress(java.lang.String)` is available to
validate a Bluetooth address.

A `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` will always be returned for a valid hardware address and type,
even if this adapter has never seen that device.

<br />

| Parameters ||
|---|---|
| `address` | `String`: valid Bluetooth MAC address. This value cannot be `null`. <br /> |
| `addressType` | `int`: Bluetooth address type. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ADDRESS_TYPE_PUBLIC` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ADDRESS_TYPE_RANDOM` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ADDRESS_TYPE_ANONYMOUS` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ADDRESS_TYPE_UNKNOWN` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothDevice` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if address is invalid |

### getScanMode

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

```
public int getScanMode ()
```

Get the current Bluetooth scan mode of the local Bluetooth adapter.

The Bluetooth scan mode determines if the local adapter is connectable and/or discoverable
from remote Bluetooth devices.

Possible values are: `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_NONE`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE`.

If Bluetooth state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, this API will return `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_NONE`.
After turning on Bluetooth, wait for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` to
get the updated value.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Returns ||
|---|---|
| `int` | scan mode. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_NONE` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#SCAN_MODE_CONNECTABLE_DISCOVERABLE` |

### getState

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

```
public int getState ()
```

Get the current state of the local Bluetooth adapter.

Possible return values are `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_ON`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_OFF`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `int` | current state of Bluetooth adapter. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_OFF` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_ON` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` - `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_TURNING_OFF` |

### isDiscovering

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

```
public boolean isDiscovering ()
```

Return true if the local Bluetooth adapter is currently in the device discovery process.

Device discovery is a heavyweight procedure. New connections to remote Bluetooth devices
should not be attempted while discovery is in progress, and existing connections will
experience limited bandwidth and high latency. Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#cancelDiscovery()` to cancel an
ongoing discovery.

Applications can also register for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_DISCOVERY_STARTED` or `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_DISCOVERY_FINISHED` to be notified when discovery starts or completes.

If Bluetooth state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, this API will return false. After turning on
Bluetooth, wait for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` to get the updated
value.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Returns ||
|---|---|
| `boolean` | true if discovering <br /> |

### isEnabled

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

```
public boolean isEnabled ()
```

Return true if Bluetooth is currently enabled and ready for use.

Equivalent to: `getBluetoothState() == STATE_ON`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if the local adapter is turned on <br /> |

### isLe2MPhySupported

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

```
public boolean isLe2MPhySupported ()
```

Return true if LE 2M PHY feature is supported.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if chipset supports LE 2M PHY feature <br /> |

### isLeAudioBroadcastAssistantSupported

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

```
public int isLeAudioBroadcastAssistantSupported ()
```

Returns `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` if the LE audio broadcast assistant
feature is supported, `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` if the feature is
not supported, or an error code.

<br />

| Returns ||
|---|---|
| `int` | whether the LE audio broadcast assistant is supported. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_UNKNOWN` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_BLUETOOTH_NOT_ENABLED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` |

### isLeAudioBroadcastSourceSupported

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

```
public int isLeAudioBroadcastSourceSupported ()
```

Returns `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` if the LE audio broadcast source
feature is supported, `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` if the feature is
not supported, or an error code.

<br />

| Returns ||
|---|---|
| `int` | whether the LE audio broadcast source is supported. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_UNKNOWN` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_BLUETOOTH_NOT_ENABLED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` |

### isLeAudioSupported

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

```
public int isLeAudioSupported ()
```

Returns `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` if the LE audio feature is supported,
`https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` if the feature is not supported, or an
error code.

<br />

| Returns ||
|---|---|
| `int` | whether the LE audio is supported. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_UNKNOWN` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_BLUETOOTH_NOT_ENABLED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` |

### isLeCodedPhySupported

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

```
public boolean isLeCodedPhySupported ()
```

Return true if LE Coded PHY feature is supported.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if chipset supports LE Coded PHY feature <br /> |

### isLeExtendedAdvertisingSupported

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

```
public boolean isLeExtendedAdvertisingSupported ()
```

Return true if LE Extended Advertising feature is supported.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if chipset supports LE Extended Advertising feature <br /> |

### isLeHighDataThroughputPhySupported

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

```
public int isLeHighDataThroughputPhySupported ()
```

Checks if LE High Data Throughput (HDT) PHY is supported.

<br />

| Returns ||
|---|---|
| `int` | the support status of the feature. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_SUPPORTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_UNKNOWN` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_BLUETOOTH_NOT_ENABLED` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#FEATURE_NOT_SUPPORTED` |

### isLePeriodicAdvertisingSupported

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

```
public boolean isLePeriodicAdvertisingSupported ()
```

Return true if LE Periodic Advertising feature is supported.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if chipset supports LE Periodic Advertising feature <br /> |

### isMultipleAdvertisementSupported

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

```
public boolean isMultipleAdvertisementSupported ()
```

Return true if the multi advertisement is supported by the chipset.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if Multiple Advertisement feature is supported <br /> |

### isOffloadedFilteringSupported

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

```
public boolean isOffloadedFilteringSupported ()
```

Return true if offloaded filters are supported.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if chipset supports on-chip filtering <br /> |

### isOffloadedScanBatchingSupported

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

```
public boolean isOffloadedScanBatchingSupported ()
```

Return true if offloaded scan batching is supported.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.

<br />

| Returns ||
|---|---|
| `boolean` | true if chipset supports on-chip scan batching <br /> |

### listenUsingInsecureL2capChannel

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

```
public BluetoothServerSocket listenUsingInsecureL2capChannel ()
```

Create an insecure L2CAP Connection-oriented Channel (CoC) `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` and
assign a dynamic PSM value. This socket can be used to listen for incoming connections. The
supported Bluetooth transport is LE only.

The link key is not required to be authenticated, i.e. the communication may be vulnerable
to person-in-the-middle attacks. Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel()`, if an encrypted and
authenticated communication channel is desired.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#accept()` to retrieve incoming connections from a listening
`https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket`.

The system will assign a dynamic protocol/service multiplexer (PSM) value. This PSM value
can be read from the `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#getPsm()` and this value will be released
when this server socket is closed, Bluetooth is turned off, or the application exits
unexpectedly.

The mechanism of disclosing the assigned dynamic PSM value to the initiating peer is
defined and performed by the application.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createInsecureL2capChannel(int)` to connect to this server
socket from another Android device that is given the PSM value.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | an L2CAP CoC BluetoothServerSocket. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | on error, for example Bluetooth not available or unable to start this CoC |

### listenUsingInsecureRfcommWithServiceRecord

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

```
public BluetoothServerSocket listenUsingInsecureRfcommWithServiceRecord (String name, 
                UUID uuid)
```

Create a listening, insecure RFCOMM Bluetooth socket with Service Record.

The link key is not required to be authenticated, i.e. the communication may be vulnerable
to Person In the Middle attacks. For Bluetooth 2.1 devices, the link will be encrypted, as
encryption is mandatory. For legacy devices (pre Bluetooth 2.1 devices) the link will not be
encrypted. Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingRfcommWithServiceRecord(java.lang.String,%20java.util.UUID)`, if an encrypted and authenticated
communication channel is desired.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#accept()` to retrieve incoming connections from a listening
`https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket`.

The system will assign an unused RFCOMM channel to listen on.

The system will also register a Service Discovery Protocol (SDP) record with the local SDP
server containing the specified UUID, service name, and auto-assigned channel. Remote
Bluetooth devices can use the same UUID to query our SDP server and discover which channel to
connect to. This SDP record will be removed when this socket is closed, or if this
application closes unexpectedly.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createInsecureRfcommSocketToServiceRecord(java.util.UUID)` to connect to this
socket from another device using the same `https://developer.android.com/reference/java/util/UUID`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `name` | `String`: service name for SDP record <br /> |
| `uuid` | `UUID`: uuid for SDP record <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | a listening RFCOMM BluetoothServerSocket <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | on error, for example Bluetooth not available, or insufficient permissions, or channel in use. |

### listenUsingL2capChannel

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

```
public BluetoothServerSocket listenUsingL2capChannel ()
```

Create a secure L2CAP Connection-oriented Channel (CoC) `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` and
assign a dynamic protocol/service multiplexer (PSM) value. This socket can be used to listen
for incoming connections. The supported Bluetooth transport is LE only.

A remote device connecting to this socket will be authenticated and communication on this
socket will be encrypted.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#accept()` to retrieve incoming connections from a listening
`https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket`.

The system will assign a dynamic PSM value. This PSM value can be read from the `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#getPsm()` and this value will be released when this server socket is
closed, Bluetooth is turned off, or the application exits unexpectedly.

The mechanism of disclosing the assigned dynamic PSM value to the initiating peer is
defined and performed by the application.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createL2capChannel(int)` to connect to this server socket from
another Android device that is given the PSM value.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | an L2CAP CoC BluetoothServerSocket. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | on error, for example Bluetooth not available or unable to start this CoC |

### listenUsingRfcommWithServiceRecord

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

```
public BluetoothServerSocket listenUsingRfcommWithServiceRecord (String name, 
                UUID uuid)
```

Create a listening, secure RFCOMM Bluetooth socket with Service Record.

A remote device connecting to this socket will be authenticated and communication on this
socket will be encrypted.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#accept()` to retrieve incoming connections from a listening
`https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket`.

The system will assign an unused RFCOMM channel to listen on.

The system will also register a Service Discovery Protocol (SDP) record with the local SDP
server containing the specified UUID, service name, and auto-assigned channel. Remote
Bluetooth devices can use the same UUID to query our SDP server and discover which channel to
connect to. This SDP record will be removed when this socket is closed, or if this
application closes unexpectedly.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createRfcommSocketToServiceRecord(java.util.UUID)` to connect to this socket
from another device using the same `https://developer.android.com/reference/java/util/UUID`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `name` | `String`: service name for SDP record <br /> |
| `uuid` | `UUID`: uuid for SDP record <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | a listening RFCOMM BluetoothServerSocket <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | on error, for example Bluetooth not available, or insufficient permissions, or channel in use. |

### listenUsingSocketSettings

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

```
public BluetoothServerSocket listenUsingSocketSettings (BluetoothSocketSettings settings)
```

Creates a listening server channel for Bluetooth connections with the specified socket
settings `https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings`.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#accept()` to retrieve incoming connections from a listening
`https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket`.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createUsingSocketSettings(android.bluetooth.BluetoothSocketSettings)` to connect
to this server socket from another Android device using the L2cap protocol/service
multiplexer(PSM) value or the RFCOMM service UUID as input.

This API requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED` permission
only when `settings.getDataPath()` is different from `https://developer.android.com/`.

This API supports `https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_RFCOMM` and {`https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_LE`
only, which can be set using `https://developer.android.com/`.
- For \`BluetoothSocket.TYPE_RFCOMM\`: The RFCOMM UUID must be provided using `https://developer.android.com/`.
- For \`BluetoothSocket.TYPE_LE\`: The system assigns a dynamic protocol/service multiplexer (PSM) value. This value can be read from `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket#getPsm()`. This value is released when the server socket is closed, Bluetooth is turned off, or the application exits unexpectedly. The mechanism for disclosing the PSM value to the client is application-defined.
- For \`BluetoothSocket.TYPE_LE\`: It is possible for a privileged application to host the L2cap server on a designated PSM channel. This is intended for peripheral devices that reserve a range of PSM values to be used to host dedicated L2cap socket servers.   
  For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.

  <br />

  <br />

  | Parameters ||
  |---|---|
  | `settings` | `BluetoothSocketSettings`: Bluetooth socket settings `https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings`. This value cannot be `null`. <br /> |

  | Returns ||
  |---|---|
  | `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` | a `https://developer.android.com/reference/android/bluetooth/BluetoothServerSocket` This value cannot be `null`. <br /> |

  | Throws ||
  |---|---|
  | `https://developer.android.com/reference/java/io/IOException` | on error, for example Bluetooth not available or unable to start this LE Connection-oriented Channel (CoC). |
  | `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if BluetoothSocket#TYPE_RFCOMM socket is requested with no UUID. |

### setName

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

```
public boolean setName (String name)
```

Set the friendly Bluetooth name of the local Bluetooth adapter.

This name is visible to remote Bluetooth devices.

Valid Bluetooth names are a maximum of 248 bytes using UTF-8 encoding(see \[Vol 2\] Part C,
Section 4.3.5), although many remote devices can only display the first 40 characters, and
some may be limited to just 20.

Note: The factory name is the result of

1. System property 'bluetooth.device.default_name'
2. Settings.Global.DEVICE_NAME
3. System property 'ro.product.model'
4. Hardcoded value 'Android'

.   
For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.   
Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: a valid Bluetooth name or null to reset to factory default <br /> |

| Returns ||
|---|---|
| `boolean` | true <br /> |

### startDiscovery

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

```
public boolean startDiscovery ()
```

Start the remote device discovery process.

The discovery process usually involves an inquiry scan of about 12 seconds, followed by a
page scan of each new device to retrieve its Bluetooth name. If BLE is supported, a
simultaneous LE scan runs until discovery ends.

This is an asynchronous call, it will return immediately. Register for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_DISCOVERY_STARTED` and `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_DISCOVERY_FINISHED` intents to determine
exactly when the discovery starts and completes. Register for `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ACTION_FOUND` to be notified as remote Bluetooth devices are found.

Device discovery is a heavyweight procedure. New connections to remote Bluetooth devices
should not be attempted while discovery is in progress, and existing connections will
experience limited bandwidth and high latency. Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#cancelDiscovery()` to cancel an
ongoing discovery. Discovery is not managed by the Activity, but is run as a system service,
so an application should always call `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#cancelDiscovery()` even if it
did not directly request a discovery, just to be sure.

Device discovery will only find remote devices that are currently *discoverable*
(inquiry scan enabled). Many Bluetooth devices are not discoverable by default, and need to
be entered into a special mode.

If Bluetooth state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`, this API will return false. After turning on
Bluetooth, wait for `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_STATE_CHANGED` with `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON` to get the updated
value.

If a device is currently bonding, this request will be queued and executed once that
device has finished bonding. If a request is already queued, this request will be ignored.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


In addition, this requires the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`
permission. For apps targeting `https://developer.android.com/` or higher, an alternative is a
strong assertion that you will never derive the physical location of the device, made by
declaring `usesPermissionFlags="neverForLocation"` on the relevant `<uses-permission>` manifest tag. However, this assertion may restrict the types of Bluetooth
devices you can interact with.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Returns ||
|---|---|
| `boolean` | true on success, false on error <br /> |

### startLeScan

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

```
public boolean startLeScan (UUID[] serviceUuids, 
                BluetoothAdapter.LeScanCallback callback)
```


**This method was deprecated
in API level 21.**   

use `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.bluetooth.le.ScanCallback)`
instead.

Starts a scan for Bluetooth LE devices, looking for devices that advertise given services.

Devices which advertise all specified services are reported using the `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback#onLeScan(android.bluetooth.BluetoothDevice,%20int,%20byte[])` callback.

This method requires the calling app to have the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission. Additionally, an app must have the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED` if it is used for BLE scan only mode
(when the adapter state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`).


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


In addition, this requires the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`
permission. For apps targeting `https://developer.android.com/` or higher, an alternative is a
strong assertion that you will never derive the physical location of the device, made by
declaring `usesPermissionFlags="neverForLocation"` on the relevant `<uses-permission>` manifest tag. However, this assertion may restrict the types of Bluetooth
devices you can interact with.

<br />

| Parameters ||
|---|---|
| `serviceUuids` | `UUID`: Array of services to look for <br /> |
| `callback` | `BluetoothAdapter.LeScanCallback`: the callback LE scan results are delivered <br /> |

| Returns ||
|---|---|
| `boolean` | true, if the scan was started successfully <br /> |

### startLeScan

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

```
public boolean startLeScan (BluetoothAdapter.LeScanCallback callback)
```


**This method was deprecated
in API level 21.**   

use `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.bluetooth.le.ScanCallback)`
instead.

Starts a scan for Bluetooth LE devices.

Results of the scan are reported using the `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback#onLeScan(android.bluetooth.BluetoothDevice,%20int,%20byte[])` callback.

This method requires the calling app to have the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission. Additionally, an app must have the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED` if it is used for BLE scan only mode
(when the adapter state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`).


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


In addition, this requires the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`
permission. For apps targeting `https://developer.android.com/` or higher, an alternative is a
strong assertion that you will never derive the physical location of the device, made by
declaring `usesPermissionFlags="neverForLocation"` on the relevant `<uses-permission>` manifest tag. However, this assertion may restrict the types of Bluetooth
devices you can interact with.

<br />

| Parameters ||
|---|---|
| `callback` | `BluetoothAdapter.LeScanCallback`: the callback LE scan results are delivered <br /> |

| Returns ||
|---|---|
| `boolean` | true, if the scan was started successfully <br /> |

### stopLeScan

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

```
public void stopLeScan (BluetoothAdapter.LeScanCallback callback)
```


**This method was deprecated
in API level 21.**   

Use `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#stopScan(android.bluetooth.le.ScanCallback)` instead.

Stops an ongoing Bluetooth LE device scan.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Parameters ||
|---|---|
| `callback` | `BluetoothAdapter.LeScanCallback`: used to identify which scan to stop must be the same handle used to start the scan <br /> |

## Protected methods

### finalize

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

```
protected void finalize ()
```

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the `finalize` method to dispose of
system resources or to perform other cleanup.


The general contract of `finalize` is that it is invoked
if and when the Java virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The `finalize` method may take any action, including
making this object available again to other threads; the usual purpose
of `finalize`, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.


The `finalize` method of class `Object` performs no
special action; it simply returns normally. Subclasses of
`Object` may override this definition.


The Java programming language does not guarantee which thread will
invoke the `finalize` method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.


After the `finalize` method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.


The `finalize` method is never invoked more than once by a Java
virtual machine for any given object.


Any exception thrown by the `finalize` method causes
the finalization of this object to be halted, but is otherwise
ignored.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Throwable` |   |