Updated implementation, based on B4XPages of https://www.b4x.com/android/forum/threads/android-bluetooth-bluetoothadmin-tutorial.14768/#content.
The code is much simpler compared to the previous example.
Note that you can call Serial.Listen without making the device discoverable. This is useful for cases where the devices were already paired once.
- Example updated with targetSdkVersion 33. Note the new method to enable Bluetooth if needed.
- Example updated with targetSdkVersion 31 requirements.
Note the new permissions in the manifest editor:
AddPermission(android.permission.ACCESS_FINE_LOCATION) AddPermission(android.permission.BLUETOOTH_ADVERTISE) AddPermission(android.permission.BLUETOOTH_CONNECT) AddPermission(android.permission.BLUETOOTH_SCAN)