當前位置:編程學習大全網 - 網站源碼 - 開發Android時,藍牙耳機已經配對和連接上之後,無法再通過廣播Action found搜索到它,是否可以再搜索到

開發Android時,藍牙耳機已經配對和連接上之後,無法再通過廣播Action found搜索到它,是否可以再搜索到

具體有什麽需求,連接成功了,不需要廣播去獲取了啊?直接從列表啟動使用就行。

《》獲取已配對的藍牙設備(android.bluetooth.BluetoothDevice)

首次連接某藍牙設備需要先配對,壹旦配對成功,該設備的信息會被保存,以後連接時無需再配對,所以已配對的設備不壹定是能連接的。

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();?

Set<BluetoothDevice> devices = adapter.getBondedDevices();?

for(int i=0; i<devices.size(); i++)?

{?

BluetoothDevice device = (BluetoothDevice) devices.iterator().next();?

System.out.println(device.getName());?

}

  • 上一篇:React中的不可變性
  • 下一篇:java eclipse 創建web project 項目 HTML 怎麽連接oracle數據庫
  • copyright 2024編程學習大全網