2010-04-27 53 views

回答

0

不是 - 因爲從安全的角度來看,重要的是讓用戶瞭解配對。這個想法是,設備配對和綁定一次,然後向前連接發生應用程序自動啓動,無需重新配對(或用戶干預)

+0

但是,Android可以隨時強制這些方法顯示一些確認彈出權? – ericn 2013-08-27 12:15:06

0

是的,可以通過應用程序進行配對。我在我的應用程序中配對。 爲此,你必須做出IBluetooth接口對象可通過這種方式:

IBluetooth mBluetoothService; 
Field fie = Class.forName(bluetoothAdapter.getClass().getName()).getDeclaredField("mService"); 
fie.setAccessible(true); 
mBluetoothService = (IBluetooth) fie.get(bluetoothAdapter); 

通過使用這個對象,你可以使用IBluetooth接口功能與設備配對。 (對於自動配對正常序列)::

mBluetoothService.setPin(deviceAddress, PIN); 
mBluetoothService.setTrust(deviceAddress); 
mBluetoothService.createBond(deviceAddress); 
mBluetoothService.setPairingConfirmation(deviceAddress, false); 
mBluetoothService.cancelPairingUserInput(deviceAddress); 

通過使用這些功能可以用任何BT設備配對編程。

相關問題