2011-08-25 65 views
1

我需要不断轮询在我的活动中获取蓝牙设备连接/断开连接,以使用当前可用的设备更新listView。 我使用btAdapter.startDiscovery(),但它不是永久性的...我如何正确获取设备的开/关事件?Android的蓝牙:如何轮询连接/断开

回答

0

我建议使用broadcastreceiver来听你正在谈论的特定事件。说到摆脱目前的发现模式后,将它保存扫描

BluetoothAdapter.ACTION_DISCOVERY_FINISHED 
BluetoothDevice.ACTION_ACL_CONNECTED 
BluetoothDevice.ACTION_ACL_DISCONNECTED 

可以使用意图额外的,以便能够从连接的设备获取名称(ECT),你甚至可以火了另一个发现模式我会读http://developer.android.com/guide/topics/wireless/bluetooth.htmlhttp://developer.android.com/reference/android/content/BroadcastReceiver.html