2013-05-26 56 views
1

我用下面的代碼在onItemClickListenerAndroid的藍牙配對意圖

  BluetoothDevice device; 
     device = btAdapter.getRemoteDevice(address); 
     Intent intent1 = new Intent("android.bluetooth.device.action.PAIRING_REQUEST"); 
     intent1.putExtra("android.bluetooth.device.extra.DEVICE", device); 
     intent1.putExtra("android.bluetooth.device.extra.PAIRING_VARIANT", 0); 
     intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     startActivity(intent1); 

它打開用戶在其中輸入引腳配對對話,但實際上它並不對。

一個非常類似的問題已經被問過,但沒有人回答了這個問題,希望我將有更多的運氣

回答

1

我不知道,如果你仍然有這個問題,因爲這個問題確實是老了,但我m做一個應用程序,完全是這樣的,所以我會分享我的代碼進行配對:

BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter(); 
device = bluetooth.getRemoteDevice(address); 

// Opens the pin dialog and then bonds the device 
device.createBond(); 

希望它能幫助某人。