Search code examples
androidbluetoothbluetooth-lowenergygatt

Start GATT Server on Android phone. Which minSdk is required?


I am going to start GATT server on my mobile phone for sharing some data to nearby devices. From official documentation API for working with LE Bluetooth was introduced in Android 4.3(18 API level).

I found some samples witch show how to run server. All of them use BluetoothLeAdvertiser which was added in Android 5.0(21 API level).

So I built two client/server sample applications and easy found my "SERVER DEVICE" in "CLIENT DEVICE", but how can I achieve that without BluetoothLeAdvertiser? In other words how can I connect to BluetoothGattServer and do not use BluetoothLeAdvertiser? It is critical for me, because my application has minSdk=19(Android 4.4).

Thanks for help!


Solution

  • Even with Bluetooth Low Energy being available in Android API level 18, you will not be able to use an Android phone in peripheral mode with API level lower than 21.

    As seen in Android Lolipop release notes:

    Android 4.3 introduced platform support for Bluetooth Low Energy (Bluetooth LE) in the central role. In Android 5.0, an Android device can now act as a Bluetooth LE peripheral device.

    Also, not all Android devices that have Lollipop support the peripheral mode. This list shows what device models are able to transmit as the server.

    You are able to use your app as the client side, there is a code example in the Android Bluetooth Low Energy documentation page.