Partager via


BluetoothDevice.CreateL2capChannel(Int32) Method

Definition

Create a Bluetooth L2CAP Connection-oriented Channel (CoC) BluetoothSocket that can be used to start a secure outgoing connection to the remote device with the same dynamic protocol/service multiplexer (PSM) value.

[Android.Runtime.Register("createL2capChannel", "(I)Landroid/bluetooth/BluetoothSocket;", "", ApiSince=29)]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")]
public Android.Bluetooth.BluetoothSocket CreateL2capChannel (int psm);
[<Android.Runtime.Register("createL2capChannel", "(I)Landroid/bluetooth/BluetoothSocket;", "", ApiSince=29)>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")>]
member this.CreateL2capChannel : int -> Android.Bluetooth.BluetoothSocket

Parameters

psm
Int32

dynamic PSM value from remote device

Returns

a CoC #BluetoothSocket ready for an outgoing connection

Attributes

Remarks

Create a Bluetooth L2CAP Connection-oriented Channel (CoC) BluetoothSocket that can be used to start a secure outgoing connection to the remote device with the same dynamic protocol/service multiplexer (PSM) value. The supported Bluetooth transport is LE only.

This is designed to be used with BluetoothAdapter#listenUsingL2capChannel() for peer-peer Bluetooth applications.

Use BluetoothSocket#connect to initiate the outgoing connection.

Application using this API is responsible for obtaining PSM value from remote device.

The remote device will be authenticated and communication on this socket will be encrypted.

Use this socket if an authenticated socket link is possible. Authentication refers to the authentication of the link key to prevent person-in-the-middle type of attacks.

Java documentation for android.bluetooth.BluetoothDevice.createL2capChannel(int).

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.

Applies to