xamarin.android - Cannot find PairingParams.PAIRING_VARIANT_CONSENT in Xamarin.Android
问题描述
I have faced with issue that when pairing request happens I got the following PairingParams.PAIRING_VARIANT_CONSENT
(= 3) pairing variant, but it is absent in ...
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
do not contain the something like PAIRING_VARIANT_CONSENT
...
Does somebody faced with the same issue ?
解决方案
就我而言,我呼吁abortBroadcast()
不显示 pin 对话框,但前提是BluetoothDevice.ExtraPairingVariant
is not 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();
}
}
推荐阅读
- vb.net - 如何在 VB.NET 中克隆 UserPrincipal 对象
- c - GSL 自适应积分给出无效指针错误
- amazon-web-services - 如何强制从 AWS S3 存储桶下载文本文件
- php - 无法将文件上传到共享点库 (Office 365),创建表单摘要时出错
- java - 我可以从java代码中获得等效的点网代码吗
- r - 删除 dplyr 的函数列表中的 NA
- powerbi - Power BI DAX:通过将某个值与某些先前计算的列值相乘来计算新列值(作为敏感性分析的一部分)
- c++ - MS VC++ 编译器错误 - 固定大小的 C 字符串花括号初始化程序
- excel - 确定所有线路是否有故障或某些线路是否正确——excel vba 中的错误处理
- git - 对多个 git 存储库进行相同的更改