Android only example of using the Python class android.broadcast.BroadcastReceiver.
This example uses the Android Bluetooth permissions that target Android 12 or higher. For earlier devices the permission names are different, but the approach used here is the same. See https://developer.android.com/guide/topics/connectivity/bluetooth/permissions .
This example does not require that Android location services are enabled.
If you wish to extend the example in a way that uses location services:
- in
buildozer.specreplace:
android.permissions = (name=android.permission.BLUETOOTH_SCAN;usesPermissionFlags=neverForLocation)
with:
android.permissions = BLUETOOTH_SCAN, ACCESS_FINE_LOCATION
- in
android_permissions.pyreplace:
self.permissions = [Permission.BLUETOOTH_SCAN]with:
self.permissions = [Permission.BLUETOOTH_SCAN,
Permission.ACCESS_FINE_LOCATION]