最終更新:2025-02-03 (月) 18:28:28 (4d)
Android/Bluetooth/開発
主なクラス
android.bluetooth.BluetoothAdapter デバイスに搭載されたBluetoothアダプタ android.bluetooth.BluetoothDevice 相手先デバイス android.bluetooth.BluetoothSocket 確立されたソケット通信 (クライアント側) android.bluetooth.BluetoothServerSocket 確立されたソケット通信 (サーバ側)
接続先デバイスの取得
リッスン
BluetoothServerSocket? BluetoothAdapter.listenUsingInsecureL2capChannel? Create an insecure L2CAP Connection-oriented Channel (CoC) BluetoothServerSocket? and assign a dynamic PSM value Android/APIレベル29 BluetoothServerSocket? BluetoothAdapter.listenUsingL2capChannel? Create a secure L2CAP Connection-oriented Channel (CoC) BluetoothServerSocket? and assign a dynamic protocol/service multiplexer (PSM) value. Android/APIレベル29 BluetoothServerSocket? BluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord? Create a listening, insecure RFCOMM Bluetooth socket with Service Record. Android/APIレベル10 BluetoothServerSocket? BluetoothAdapter.listenUsingRfcommWithServiceRecord Create a listening, secure RFCOMM Bluetooth socket with Service Record. Android/APIレベル5
接続
BluetoothSocket BluetoothDevice.createInsecureL2capChannel?(int psm) Android/APIレベル29 BluetoothSocket BluetoothDevice.createL2capChannel?(int psm) Android/APIレベル29 BluetoothSocket BluetoothDevice.createInsecureRfcommSocketToServiceRecord?(UUID uuid) Android/APIレベル10 BluetoothSocket BluetoothDevice.createRfcommSocketToServiceRecord(UUID uuid) Create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device using SDP lookup of uuid. Android/APIレベル5
Android/Bluetooth/サンプル
https://github.com/googlearchive/android-BluetoothChat/
https://github.com/android/connectivity-samples