我遇到过这样的问题,当配对请求发生时,我得到了下面的PairingParams.PAIRING_VARIANT_CONSENT (= 3)配对变体,但它在...
object obj = intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
BluetoothDevice device = (obj as BluetoothDevice)!;
var extraPairingVariant = intent.GetIntExtra(BluetoothDevice.ExtraPairingVariant, 0);
switch (extraPairingVariant)
{
case BluetoothDevice.PairingVariantPin:
{
...
}
break;
case BluetoothDevice.PairingVariantPasskeyConfirmation:
{
...
}
break;
case \* 3, what constant should be here ?? *\
{
...
}
break;
}... BluetoothDevice不包含像PAIRING_VARIANT_CONSENT这样的东西...
有没有人面临同样的问题?
发布于 2021-03-02 22:00:05
在我的例子中,我调用abortBroadcast()不显示pin对话框,但仅当BluetoothDevice.ExtraPairingVariant不是3时才显示。否则,必须显示一个对话框,让用户接受配对。当您删除已配对的设备并要求重新配对时,就会出现此状态。(https://developer.android.com/reference/com/google/android/things/bluetooth/PairingParams.html#pairing_variant_consent)
BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
if (action == BluetoothDevice.ActionPairingRequest)
{
device.SetPin(System.Text.Encoding.UTF8.GetBytes("####"));
int exraPairingVariant = intent.GetIntExtra(BluetoothDevice.ExtraPairingVariant, 0);
if (exraPairingVariant == BluetoothDevice.PairingVariantPasskeyConfirmation || exraPairingVariant == BluetoothDevice.PairingVariantPin)
{
InvokeAbortBroadcast();
}
}https://stackoverflow.com/questions/65467956
复制相似问题