#VS2015 – Listing #BlueTooth LE Devices in #Android with #Xamarin


Today I will begin with a series of posts based on my work with Xamarin and BlueTooth (LE) Low Energy devices. I’ve already written a couple of posts on how to work with Windows 10 Universal Apps and BlueTooth LE, in those examples I shared my experiences connecting a Windows 10 device to a heart rate sensor and display the HR value in an App. Today’s example is simpler: show all BLE Devices that can be detected by an Android device.

The first thing we will do is to create an Xamarin Android app.

Note: If you don’t know Xamarin, in the references section I have shared a link with resources to get started with Android.

The next step is to add a button and a multiline text in the main view. The app flow is easy: press the button, and then the BLE Devices found will be listed.

The next step is to identify the button and the text box. Also we need to creating a new instance of BlueToothLeScanner to list the BlueTooth Low Energy devices and subscribe to the ScanTimeOutElapsed() and DeviceDiscovered() events.

Important: From what I’ve seen, there are 2 modes of working with BlueTooth Devices. For normal devices, you must use the Adapter class, which is obtained from the BlueTooth system service, lines 30 to 32. In the case of BlueTooth LE, this is not a system service, simply have to create a new instance of BlueToothLeScanner and work with this object, lines 34 to 36.

Then in the DeviceDiscovered() event, we will show the new device in the box of text, line 45-29.

The same will do when the process of scanning-error, lines 39 to 43.

Finally, at the click of the button will begin the process of searching for BLE Devices.

The result of the app in operation is as follows

I’m not sure why the app raises so many times the same device. While that is not a problem, I have a couple of nights to take it forward 😉

You can download the code from here https://github.com/elbruno/Blog/tree/master/Xamarin/AndroidApp4

Saludos @ Madrid

/El Bruno


– El Bruno, posts on BlueTooth LE https://elbruno.com/category/BLE/

– Polar Heart Rate Sensor H7, http://www.polar.com/us-en/products/accessories/H7_heart_rate_sensor

– Xamarin, Hello Android http://developer.xamarin.com/guides/android/getting_started/hello,android/

– Xamarin Android.Bluetooth.LE.BluetoothLeScanner http://developer.xamarin.com/api/type/Android.Bluetooth.LE.BluetoothLeScanner/

[Tags Visual Studio 2015, Xamarin, Bluetooth, BLE, Android, English Post]


    1. Hola Manuel,
      no te entiendo? no te funciona? No tengo un android a mano para probarlo ahora, pero en cuanto lo tenga actualizaré el post si ha dejado de funcionar


      1. Gracias amigo!.. Ya intente con dispositivos y no me detecta nada.. probe con lolipop y android 4.4 . . alguna otro ejemplo que tetnga?.. gracias amigo muy util


  1. is this a joke? this code has lots of mistakes and will not work. don’t waste your time guys


    1. O tal vez no seas lo suficientemente intelligente para hacerlo funcionar?

      Porque con ese nombre de troll y con codigo de Xamarin de hace 3 anios, hace falta un poco de mania para actualizar el codigo



Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.