安卓下如何配對?
開啟藍牙后開始搜索,可以搜索到新的設備然后用
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
mArrayAdapter.add(device.getName() + "/n" + device.getAddress());
devices.add(device);
}
}
};
來接收新的設備
問題是怎么配對呢?
客戶端的情況下:
我看網上可以用下面的代碼來進入 選擇藍牙設備的界面,里面有搜索出來的全部設備(View)
Intent blueList = new Intent("android.bluetooth.devicepicker.action.LAUNCH");
startActivity(blueList);
當我點一下其中一個設備(View)界面就回傳我自己的Activity了,我怎么能獲取他到底是點了哪個設備呢
這樣我才能配對或者連接啊
怎么實作配對啊,網上說的都是一搜索到設備就馬上自動配對,我想的是選擇其中一個設備配對啊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/145413.html
標籤:網絡通信
下一篇:MT8788芯片資料技術分享
