模拟点击ok按钮android

模拟点击ok按钮android,android,bluetooth,Android,Bluetooth,我收到蓝牙配对请求,只需按ok按钮。我想通过代码来实现这一点。我该怎么做?我可以在“行动”\u“债券”\u“状态”\u“更改”事件中这样做吗 如果使用.performClick()执行此操作,如何从配对蓝牙对话框中获取对“确定”按钮的引用 到目前为止,我有一个广播接收器,它使用onReceive功能: if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) { int prevBondState = in

我收到蓝牙配对请求,只需按ok按钮。我想通过代码来实现这一点。我该怎么做?我可以在“行动”\u“债券”\u“状态”\u“更改”事件中这样做吗

如果使用.performClick()执行此操作,如何从配对蓝牙对话框中获取对“确定”按钮的引用

到目前为止,我有一个广播接收器,它使用onReceive功能:

if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
            int prevBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, -1);
            int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            Log.i(TAG, "bond state changed");
            Log.i(TAG, "device:" + device.getName());
            Log.i(TAG, "prev state:" + prevBondState);
            Log.i(TAG, "curr state:" + bondState);
            if (prevBondState == BluetoothDevice.BOND_BONDING) {

                if (bondState == BluetoothDevice.BOND_BONDED) {
                    Globals.sendStatus("bluetooth", device.getName() + " pairing successful");
                    Log.i(TAG, device.getName() + " pairing successful");
                }
            } else if (prevBondState == BluetoothDevice.BOND_BONDED) {
                if (bondState == BluetoothDevice.BOND_NONE) {
                    Log.i(TAG, device.getName() + " unpairing successful");
                    Globals.sendStatus("bluetooth", device.getName() + " unpaired");
                }
            }
        }
您可以尝试()方法。这将触发与按钮关联的
onClickListener

myButton.performClick();

但是,如何从配对请求对话框中获取对“确定”按钮的引用?@Iulian932您能显示一些代码吗?然后,如果我能想到一些措施,我可以提出一些建议。平台可能为广播接收器I内的此类事件提供一些接口guess@Iulian932试试这些,我没用过,所以我帮不了你