Thank you for your answer.
The thread does not exactly match our case. It concerns not receiving any
Bluetooth events at all. In our case, we do receive the ActionFound event but
not ActionDiscoveryStarted or ActionDiscoveryFinished.
This is what we do:
Register:
IntentFilter filter = new IntentFilter();
filter.AddAction(BluetoothAdapter.ActionDiscoveryStarted);
filter.AddAction(BluetoothAdapter.ActionDiscoveryFinished);
filter.AddAction(BluetoothDevice.ActionFound);
RegisterReceiver(moReceiver, filter);
Receiver:
private class DiscoveryReceiver : BroadcastReceiver
{
private String msDeviceName = String.Empty;
public event BluetoothDeviceFound DeviceFound;
public override void OnReceive(Context context, Intent intent)
{
String action = intent.Action;
// When discovery finds a device
if (action == BluetoothDevice.ActionFound)
{
// called several times
// Get the BluetoothDevice object from the Intent
BluetoothDevice device =
intent.GetParcelableExtra(BluetoothDevice.ExtraDevice) as BluetoothDevice;
if (device.Name.ToLower().Contains(msDeviceName.ToLower()))
{
if (DeviceFound != null)
{
DeviceFound(device);
}
BluetoothAdapter.DefaultAdapter.CancelDiscovery();
}
}
else if (action == BluetoothAdapter.ActionDiscoveryStarted)
{
// never called
}
else if (action == BluetoothAdapter.ActionDiscoveryFinished)
{
// never called
}
}
}
Any idea what might be wrong here?
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Jonathan Pryor
Gesendet: Donnerstag, 24. Mai 2012 19:32
An: Discussions related to Mono for Android
Betreff: Re: [mono-android] Bluetooth Discovery Events
On May 21, 2012, at 8:42 AM, Hänke, Maik wrote:
> can someone confirm that it is not possible to receive the
> BluetoothAdapter.ActionDiscoveryStarted
> orBluetoothAdapter.ActionDiscoveryFinished event when searching for Bluetooth
> devices? I implemented a BroadcastReceiver that is registered to 3 events,
> those two from above and BluetoothDevice.DeviceFound. However, it seems that
> only the DeviceFound event is being sent.
I would guess that you're hitting:
http://stackoverflow.com/a/9430115/83444
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid