C# 通过Xamarin.Forms中的BLE清除键合(配对)信息
我必须从设备中删除配对(绑定)信息,但执行该操作后,返回蓝牙设置并检查配对设备,它仍显示为已配对。它没有清除信息。 我们提供的地址是:C# 通过Xamarin.Forms中的BLE清除键合(配对)信息,c#,xamarin,xamarin.forms,bluetooth-lowenergy,C#,Xamarin,Xamarin.forms,Bluetooth Lowenergy,我必须从设备中删除配对(绑定)信息,但执行该操作后,返回蓝牙设置并检查配对设备,它仍显示为已配对。它没有清除信息。 我们提供的地址是:F8:F6:35:D6:35:64 提前感谢您的解决方案。这必须在特定于平台的代码中处理 在iOS上这是不可能的。只能在设置中手动“遗忘” 对于Android部分。对于Android,让手机以一种方式配对蓝牙列表,然后通过反射机制取消蓝牙配对 BluetoothAdapter bluetoothAdapter; IEnumerable<Blueto
F8:F6:35:D6:35:64
提前感谢您的解决方案。这必须在特定于平台的代码中处理 在iOS上这是不可能的。只能在设置中手动“遗忘”
对于Android部分。对于Android,让手机以一种方式配对蓝牙列表,然后通过反射机制取消蓝牙配对
BluetoothAdapter bluetoothAdapter;
IEnumerable<BluetoothDevice> bondeddevices;
private void removepairdevice()
{
bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
bondeddevices = bluetoothAdapter.BondedDevices;
foreach(BluetoothDevice device in bondeddevices)
{
unpairdevice(device);
}
}
private void unpairdevice(BluetoothDevice device)
{
try
{
Method m = device.Class.GetMethod("removeBond",null);
m.Invoke(device,null);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
BluetoothAdapter BluetoothAdapter;
i可数绑定设备;
私有void removepairdevice()
{
bluetoothAdapter=bluetoothAdapter.DefaultAdapter;
bondeddevices=bluetoothAdapter.bondeddevices;
foreach(bondeddevices中的蓝牙设备)
{
非配对装置(装置);
}
}
私有无效未配对设备(蓝牙设备)
{
尝试
{
方法m=device.Class.GetMethod(“removeBond”,null);
m、 调用(设备,空);
}
捕获(例外e)
{
控制台写入线(e.Message);
}
}
请发布您试图使用的代码,以移除粘合/配对。您共享的类中的代码越多,我们就能够更快更好地提供帮助