2014-05-17 130 views
1

我是刚接触android并尝试以编程方式连接BluetoothDevice。设备有一个PIN。连接到设备是在另一个线程比UI。到目前为止,我已经遵循How to programmatically pair a bluetooth device on Android的示例。Android:隐藏配对对话框

BluetoothDevice.ACTION_PAIRING_REQUEST我将字符串转换为byte []并执行setPin调用。配对对话框弹出并消失。像

 Method createBondMethod1 = device.getClass().getMethod("cancelPairingUserInput"); 
     Boolean returnValue2 = (Boolean) createBondMethod1.invoke(device); 

的任何行动都未能上setPin。 当调用device.createBond()时触发BluetoothDevice.ACTION_PAIRING_REQUEST

问题是我该如何隐藏配对对话框?

谢谢。

回答

0

我发现的唯一的解决办法是使用到dimiss所有系统对话框:

getContext().sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); 

但问题是捕捉合适的时机dimiss它,和可信的解决这个问题必须是不显示该对话框,...但我认为唯一的解决方案将可以修改bluetoothDialog apk在系统中不显示该意图。

如果有人知道更好的解决方案,请告诉我们!