Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中访问BluetoothPairingDialog.java?_Android_Bluetooth_Android Bluetooth - Fatal编程技术网

如何在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上对我有效(不知道它是否适用于较新版本)。

我知道这种方法,但我想知道如何访问配对对话框,谢谢您的回复。