2010-04-27 126 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设备配对编程。

相关问题