我需要编写一个跨平台应用程序来搜索蓝牙设备和 WiFi 网络,显示有关设备和网络的信息。我使用ManagedWifi和InTheHand.Net.Personal 库在 Windows 窗体上编写了此类应用程序,但我无法在 xamarin 上使用这些库编写。
到目前为止,我尝试只编写 wifi 扫描,编译时出现以下错误:
MCG0004:InternalAssert 断言失败:意外的内联数组元素类型。[未知] MyProject.UWP 期间
甚至可以用一个库为所有设备编写这样的应用程序,还是您需要为每个设备使用自己的库?
这两个选项都是“正确的”。有必要涉及系统内部类的实现。Android https://developer.xamarin.com/api/namespace/Android.Bluetooth/
iOS https://developer.xamarin.com/api/namespace/MonoTouch.CoreBluetooth/
https://developer.xamarin.com/api/type/Android.Net.Wifi.WifiManager/ https://developer.xamarin.com/api/namespace/Android.Net.Wifi/
或者寻找现成的插件(这里是你的口味)。
https://github.com/xamarin/mobile-samples/tree/master/BluetoothLEExplorer
https://github.com/xabre/xamarin-bluetooth-le
但存在一个问题,Apple 没有提供列出可用 Wi-Fi 的 API(仅列出当前状态)。所以应该可以排除。