Xamarin BT扫描回调和消息中心

时间:2018-08-28 08:26:38

标签: xamarin xamarin.forms xamarin.android

我正在尝试从OnScanResult发送消息或广播意图用于ble设备,但我不断收到异常

public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);
            Intent i = new Intent(BluetoothDevice.ActionFound);
            i.PutExtra(BluetoothDevice.ExtraDevice, i);
            var device = result.Device;

            if (device != null)
            {
                Android.App.Application.Context.SendBroadcast(i);
                //  MessagingCenter.Send<IScanSender, Android.Bluetooth.BluetoothDevice>(this, "btScanner", device);

            }


        }

我得到

Java.Lang.SecurityException: Permission Denial: not allowed to send broadcast android.bluetooth.device.action.FOUND

广泛意向

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

用于尝试发送消息

0 个答案:

没有答案