BluetoothDevice.Disconnect Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Disconnects all connected bluetooth profiles between the local and remote device.
[Android.Runtime.Register("disconnect", "()I", "", ApiSince=37)]
public int Disconnect();
[<Android.Runtime.Register("disconnect", "()I", "", ApiSince=37)>]
member this.Disconnect : unit -> int
Returns
BluetoothStatusCodes#SUCCESS upon successful initiation of the operation,
otherwise an error code.
- Attributes
Remarks
Disconnects all connected bluetooth profiles between the local and remote device. Disconnection is asynchronous, so you should listen to each profile's broadcast intent ACTION_CONNECTION_STATE_CHANGED to verify whether disconnection was successful. For example, to verify a2dp is disconnected, you would listen for BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED. Once all profiles have disconnected, the ACL link should come down and ACTION_ACL_DISCONNECTED should be broadcast.
In the rare event that one or more profiles fail to disconnect, call this method again to send another request to disconnect each connected profile.
This method requires the calling app to have the Manifest.permission.BLUETOOTH_CONNECT permission. Additionally, an app must either have both Manifest.permission.BLUETOOTH_PRIVILEGED or be associated with the Companion Device manager (see android.companion.CompanionDeviceManager.associate(AssociationRequest,android.companion.CompanionDeviceManager.Callback,Handler)). For apps targeting Build.VERSION_CODES.S or or higher, this requires the Manifest.permission.BLUETOOTH_CONNECT permission which can be gained with android.app.Activity.requestPermissions(String[],int).
Android reference for android.bluetooth.BluetoothDevice.disconnect.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.