如何在android中访问BluetoothPairingDialog.java?
当蓝牙配对对话框出现时,有没有办法强制点击“配对按钮”如何在android中访问BluetoothPairingDialog.java?,android,bluetooth,android-bluetooth,Android,Bluetooth,Android Bluetooth,当蓝牙配对对话框出现时,有没有办法强制点击“配对按钮” 我不知道如何访问配对对话框,但我可以通过以下方式“强制”配对: 1) 为操作注册广播接收器: android.bluetooth.device.action.PAIRING_REQUEST 2) 收到动作后,使用反射“强制”销: String DEVICE_PIN = "12345"; final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXT
我不知道如何访问配对对话框,但我可以通过以下方式“强制”配对: 1) 为操作注册广播接收器:
android.bluetooth.device.action.PAIRING_REQUEST
2) 收到动作后,使用反射“强制”销:
String DEVICE_PIN = "12345";
final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (intent.getAction().equals("android.bluetooth.device.action.PAIRING_REQUEST")) {
byte[] pin = (byte[]) BluetoothDevice.class.getMethod("convertPinToBytes", String.class).invoke(BluetoothDevice.class, ARDUINO_PIN);
BluetoothDevice.class.getMethod("setPin", byte[].class).invoke(device, pin);
}
它在GB和ICS上对我有效(不知道它是否适用于较新版本)。我知道这种方法,但我想知道如何访问配对对话框,谢谢您的回复。