Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin 蓝牙LE不检测设备_Xamarin_Xamarin.forms_Bluetooth_Xamarin.android_Bluetooth Lowenergy - Fatal编程技术网

Xamarin 蓝牙LE不检测设备

Xamarin 蓝牙LE不检测设备,xamarin,xamarin.forms,bluetooth,xamarin.android,bluetooth-lowenergy,Xamarin,Xamarin.forms,Bluetooth,Xamarin.android,Bluetooth Lowenergy,我尝试使用此库中为Xamarin编写的did检测设备,但设备发现0 包括android中必要的宣言。将扫描时间增加到30秒,但什么都没有。已启用蓝牙功能,版本4.0 华硕Z00ED设备(安卓6.0-API 23)。该项目的目标是安卓8.1。试图在清单中切换Android的目标版本(8.0,9.0),但也没有检测到 缺乏检测的原因还有什么 public class Page6 : ContentPage { IBluetoothLE ble; IAdapte

我尝试使用此库中为Xamarin编写的did检测设备,但设备发现0

包括android中必要的宣言。将扫描时间增加到30秒,但什么都没有。已启用蓝牙功能,版本4.0

华硕Z00ED设备(安卓6.0-API 23)。该项目的目标是安卓8.1。试图在清单中切换Android的目标版本(8.0,9.0),但也没有检测到

缺乏检测的原因还有什么

public class Page6 : ContentPage
    {
        IBluetoothLE ble;
        IAdapter adapter;
        ObservableCollection<IDevice> deviceList;
        Label label;

        public Page6()
        {
            ble = CrossBluetoothLE.Current;
            adapter = CrossBluetoothLE.Current.Adapter;
            deviceList = new ObservableCollection<IDevice>();

            label = new Label { Text = "Welcome to Xamarin.Forms!" };
            var buttonList = new Button() { Text = "Devices List" };
            buttonList.Clicked += ButtonList_Clicked;

            Content = new StackLayout
            {
                Children = {
                    label,
                    buttonList,
                }
            };
        }

        private async void ButtonList_Clicked(object sender, EventArgs e)
        {
            deviceList.Clear();
            adapter.ScanTimeout = 30000;
            adapter.DeviceDiscovered += (s, a) =>
            {
                deviceList.Add(a.Device);
            };

            await adapter.StartScanningForDevicesAsync(); // сканирование

            label.Text = deviceList.Count.ToString();
        }
    }
公共类第6页:内容页
{
易卜鲁埃;
IAdapter适配器;
可观察收集设备主义者;
标签;
公共页6()
{
ble=交叉牙。电流;
适配器=交叉螺纹牙.Current.adapter;
deviceList=新的ObservableCollection();
label=newlabel{Text=“欢迎使用Xamarin.Forms!”;
var buttonList=new Button(){Text=“设备列表”};
buttonList.Clicked+=buttonList\u Clicked;
内容=新的堆栈布局
{
儿童={
标签,
按钮列表,
}
};
}
私有异步无效按钮列表\u已单击(对象发送方,事件参数e)
{
魔鬼主义者;
adapter.ScanTimeout=30000;
adapter.DeviceDiscovered+=(s,a)=>
{
添加(一个设备);
};
等待适配器。StartScanningForDevicesAsync();//ааааааааа
label.Text=deviceList.Count.ToString();
}
}

从AndroidManifest.xml中的uses sdk标记中删除android:targetSdkVersion,一切正常。我们项目的完整标签:

<uses-sdk android:minSdkVersion="15" />


您请求过位置权限吗?@Emil是的,我已经为“访问粗略位置”、“访问精细位置”、“蓝牙”、“蓝牙管理”授予了权限。您是否明确请求过它们,或者您刚刚在清单中声明过它们?@Emil Only manifest,我添加了屏幕快照这是怎么可能的?这些是从gradle文件生成的