【发布时间】:2016-08-23 22:36:41
【问题描述】:
我刚开始看 xamarin,现在我想扫描蓝牙设备。因此我使用以下代码:
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
bluetoothAdapter.StartDiscovery();
我有以下class 来获取结果:
[BroadcastReceiver]
[IntentFilter(new [] {BluetoothAdapter.ActionDiscoveryFinished})]
public class BluetoothReceiver : BroadcastReceiver
{
public BluetoothReceiver()
{
}
public override void OnReceive(Context context, Intent intent)
{
if (BluetoothAdapter.ActionDiscoveryFinished.Equals(intent.Action))
{
}
}
}
我还将我的应用程序的权限设置为BLUETOOTH 和BLUETOOTH_ADMIN。一切正常,OnReceive-Method 被正确调用。我现在的问题是:如何从 OnReceive-Method 的参数中获取找到的设备?
【问题讨论】:
标签: c# android xamarin bluetooth