We have brand new support on Android as of February 2013. It of course is compiled using Xamarin's MonoDroid toolset.
There is support for Radio, DeviceInfo, Client.Connect, sending and receiving data, Discovering known devices, and Listener. It has been tested on a Nexus 7 and a Samsung Tab 2 7.0 device.
The library project file is in ...\ITH.Net.Android\
The current library project file targets version 2.3, i.e. API Level 10,
. There is a solution file at ...\AndroidAaaa\
A version of my cross-platform testing app has been created in ...\Testing\AndroidMenuTesting\
and the ~140 commands are displayed in the AppBar menu system. Press your device menu button to open that, on most devices with the vertical three dots at
bottom-right. A few buttons provide shortcuts GetAllRadios
, and Listen
. See the screenshot below.
"Note: Most methods require the BLUETOOTH
permission and some also require the
We also need permission INTERNET
because we use NetworkStream
. If that becomes a problem we can maybe look at a workaround.
- Radio: Class of Device, versions, setting mode.
- DeviceInfo: Setting name, LastUsed, Connected, versions, GetServiceRecords, SetServiceState, and InstalledServices.
- Client.Connect: Available, DataAvailable, Connected, Client, LingerState, and LinkKey/Policy.
- Discovery Devices:
- Listener: Publishing custom Service Records, listening on a specific port number, and setting Service Class bits, LocalEndPoint is blank, and Pending. (Setting Service Name is supported.)
- Security: No support.
Android API Level
We've used only functions from Android API Level 10, i.e. GINGERBREAD_MR1. We lose BluetoothSocket.isConnected by not using Level 14, which affects
. (We could probably get down to Level 5, if using createInsecureRfcommSocketToServiceRecord and listenUsingInsecureRfcommWithServiceRecord weren't required).
Support Device Discovery. So change AndroidBthClient to be a subclass of CommonDiscoveryBluetoothClient, create and register an Android BroadcastReceiver in AndroidBthInquiry which calls back whenever a device-found event occurs. That will provide
support for both in-range and live discovery.
Check what Finalizers are required. Listener, and BluetoothClient/Stream.
- Provide socket errors. Currently we'll just pass any Mono-Android exceptions.
- Add Android to
Feature support table page.
||Compiling to target the Mono Android platform -- not to do with Bluetooth API
||Include the 32feet.NET support for Bluetooth using the Android Bluetooth API
||Include the Mock Android Bluetooth API classes
||Exclude any WinForms usage, needed for instance when targeting Android
||Hide special case Widcomm dependency checking in BluetoothFactory
||Hide code in e.g. BluetoothWin32Authentication referencing MSFT Bluetooth structs etc
For real use compiling for Android
As used by the preliminary project ITH.Net.Android.csproj
For running in the emulator add the FAKE_ANDROID_BTH_API
define, which allows Radio, Devices, and Discovery currently.
For test on desktop Windows (project file FX2)
Do not reference the Mono.Android.dll
. This includes Mocking of the Android API.
For -- useless?? -- compile on desktop Windows (project file FX2)
Add reference to Mono.Android.dll
, along with
The latter is required since System.Drawing.Size is also included in the Mono.Android.dll and so conflicts with that from the FCL's System.Drawing.dll.