# BluetoothProfileManager

Summary:[Methods](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#)  

# BluetoothProfileManager

`
public

final

class
BluetoothProfileManager
`  
`

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


``


`

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

<br />

*** ** * ** ***

Allows applications to enable/disable Bluetooth profiles on the system.

Usage of this API triggers a restart of the Bluetooth stack, and the changes take effect only after all the Bluetooth services have been restarted.

Usage:  

```
 BluetoothProfileManager profileManager = BluetoothProfileManager.getInstance();

 List enabledProfiles = profileManager.getEnabledProfiles();
 String enabled = "";
 for (Integer profile : enabledProfiles) {
   enabled += ("" + profile + ", ");
 }
 Log.d(TAG, "Enabled Profiles - " + enabled);

 Log.d(TAG, "Enabling A2dp source mode.");
 List toEnable = Arrays.asList(BluetoothProfile.A2DP);
 List toDisable =
   Arrays.asList(BluetoothProfile.A2DP_SINK, BluetoothProfile.AVRCP_CONTROLLER);
 profileManager.enableAndDisableProfiles(toEnable, toDisable);
 
```

Certain configurations of profiles are invalid and behave differently.

- [A2DP](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile#A2DP)and[A2DP_SINK](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile#A2DP_SINK)profiles cannot be enabled together. Doing so will throw an[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html).
- [GATT](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile#GATT)profile cannot be disabled. It is active if Bluetooth is ON.
- [GATT_SERVER](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile#GATT_SERVER)profile cannot be controlled using these APIs. Using them will have no effect. It is always active in conjunction with[GATT](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile#GATT).

<br />

## Summary

|                                                                                                                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                                                                                                                              ||
|---------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean`                                                                                                                                  | ` `[disableProfiles](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#disableProfiles(java.util.List<java.lang.Integer>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`> toDisable) ` Disables the specified Bluetooth profiles.                                                                                                                                                                                                                 |
| ` boolean`                                                                                                                                  | ` `[enableAndDisableProfiles](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#enableAndDisableProfiles(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`> toEnable, `[List](https://developer.android.com/reference/java/util/List)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`> toDisable) ` Enables/Disables the specified Bluetooth profiles. |
| ` boolean`                                                                                                                                  | ` `[enableProfiles](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#enableProfiles(java.util.List<java.lang.Integer>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`> toEnable) ` Enables the specified Bluetooth profiles.                                                                                                                                                                                                                     |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`>` | ` `[getEnabledProfiles](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#getEnabledProfiles())`() ` Fetch the list of Bluetooth Profiles which are currently enabled in the system.                                                                                                                                                                                                                                                                                                                                                         |
| ` static `[BluetoothProfileManager](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager)    | ` `[getInstance](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#getInstance())`() ` Fetch an instance of[BluetoothProfileManager](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager)                                                                                                                                                                                                                                                                                                    |
| ` boolean`                                                                                                                                  | ` `[setEnabledProfiles](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#setEnabledProfiles(java.util.List<java.lang.Integer>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`> profiles) ` Sets the specified profiles to be enabled and disables all the other profiles.                                                                                                                                                                        |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                                                                                                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                                                                                                                                                                                                                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                                                                                                                                                                                                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                                                                                                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                                                                                                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                                                                                                                                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                                                                                                                                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                                                                                                                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long, int))`(long millis, int nanos) ` Causes the current thread to wait until another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long millis) ` Causes the current thread to wait until either another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object, or a specified amount of time has elapsed.                                                                 | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object.                                                                                                                                  | ||

## Public methods

### disableProfiles

```
boolean disableProfiles (List<Integer> toDisable)
```

Disables the specified Bluetooth profiles.

This method disables the specified profiles from the existing set of enabled profiles. Profiles not specified in the parameters will remain unaffected.

<br />

|                                                                           Parameters                                                                           ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `toDisable` | `List`: List of[BluetoothProfile](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile)to disable. <br /> |

|                                                 Returns                                                 ||
|-----------|----------------------------------------------------------------------------------------------|
| `boolean` | False if unable to disable profile or if profile is already disabled. True otherwise. <br /> |

|                                                                       Throws                                                                        ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | when the connection to the server has died. |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | when profiles configuration is invalid.     |

### enableAndDisableProfiles

```
boolean enableAndDisableProfiles (List<Integer> toEnable, 
                List<Integer> toDisable)
```

Enables/Disables the specified Bluetooth profiles.

This method enables/disables the specified profiles on the device. Profiles not specified in the parameters will remain unaffected.

<br />

|                                                                           Parameters                                                                           ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `toEnable`  | `List`: List of[BluetoothProfile](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile)to enable. <br />  |
| `toDisable` | `List`: List of[BluetoothProfile](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile)to disable. <br /> |

|                                               Returns                                                ||
|-----------|-------------------------------------------------------------------------------------------|
| `boolean` | False if unable to modify profile state or if no change is needed. True otherwise. <br /> |

|                                                                       Throws                                                                        ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | when the connection to the server has died. |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | when profiles configuration is invalid.     |

### enableProfiles

```
boolean enableProfiles (List<Integer> toEnable)
```

Enables the specified Bluetooth profiles.

This method enables the specified profiles in addition to the already enabled profiles. Profiles not specified in the parameters will remain unaffected.

<br />

|                                                                          Parameters                                                                          ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `toEnable` | `List`: List of[BluetoothProfile](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile)to enable. <br /> |

|                                                Returns                                                ||
|-----------|--------------------------------------------------------------------------------------------|
| `boolean` | False if unable to enable profile or if profile is already enabled. True otherwise. <br /> |

|                                                                       Throws                                                                        ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | when the connection to the server has died. |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | when profiles configuration is invalid.     |

### getEnabledProfiles

```
List<Integer> getEnabledProfiles ()
```

Fetch the list of Bluetooth Profiles which are currently enabled in the system.

<br />

|                                                                     Returns                                                                      ||
|------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`>` | <br /> |

|                                                                    Throws                                                                     ||
|--------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | when the connection to the server has died. |

### getInstance

```
BluetoothProfileManager getInstance ()
```

Fetch an instance of[BluetoothProfileManager](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager)

<br />

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [BluetoothProfileManager](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager) | <br /> |

|                                                                              Throws                                                                              ||
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if a connection cannot be established to the back-end service. |

### setEnabledProfiles

```
boolean setEnabledProfiles (List<Integer> profiles)
```

Sets the specified profiles to be enabled and disables all the other profiles.

This method will remove all previous state and only enable the specified profiles.

<br />

|                                                                            Parameters                                                                            ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `profiles` | `List`: List of[BluetoothProfile](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile)to be enabled. <br /> |

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

|                                                                       Throws                                                                        ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | when the connection to the server has died. |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | when profiles configuration is invalid.     |

-

  ## Interfaces

  - [BluetoothConnectionCallback](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothConnectionCallback)
  - [BluetoothPairingCallback](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothPairingCallback)
-

  ## Classes

  - [BluetoothClassFactory](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothClassFactory)
  - [BluetoothConfigManager](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothConfigManager)
  - [BluetoothConnectionManager](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothConnectionManager)
  - [BluetoothPairingCallback.PairingError](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothPairingCallback.PairingError)
  - [BluetoothProfile](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfile)
  - [BluetoothProfileManager](https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothProfileManager)
  - [ConnectionParams](https://developer.android.com/reference/com/google/android/things/bluetooth/ConnectionParams)
  - [PairingParams](https://developer.android.com/reference/com/google/android/things/bluetooth/PairingParams)