Android的 - 蓝牙设备连接播放蓝牙、设备、Android

2023-09-08 09:10:40 作者:酒醉人不归

我想有一个广播接收器监听连接BT的设备。有谁告诉我哪广播我要听?我试图 android.bluetooth.device.action.ACL_CONNECTED ,但它似乎并没有工作。

I want to have a broadcast receiver listening for BT devices connecting. Could anybody tell me which broadcast I have to listen to? I tried android.bluetooth.device.action.ACL_CONNECTED but it doesn't seem to work.

感谢您。

推荐答案

您可以通过使用 BroadcastReceiver.onReceive()函数里以下拉设备:

You can pull the device by using the following inside your BroadcastReceiver.onReceive() function:

BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);