Android Question Services in Android 10+

jemajuca

Member
Licensed User
Hi!
My app was working OK except in Android 10.
It has the mandatory location permission ACCESS_FINE_LOCATION because it must scan for Bluetooth devices.
There is a service that runs only when the SO is pairing with the Bluetooth device.
In Android 10 the service seems not to start. (no errors shown in the unfiltered log)
Things I have tried:
-Update to B4A v10
-Android sdk platform 29 and targetSdkVersion="29"
-As noted in the post https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#content added to the manifest this line:
B4X:
SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
(Changing the service name)
The results are the same.
The service don't start.
Some doubts now:
Must I add the manifest line somewhere specific position? Here: https://developer.android.com/preview/privacy/foreground-services says that it may be declared in the "service section" of the manifest. Is this relevant?
Is a notification mandatory?
 

jemajuca

Member
Licensed User
The app scans for known Bluetooth LE devices.
If one is found, the user is prompted to accept its enrollment.
The service is started and keep waiting some intents.
The intents declared in the manifest are:
B4X:
AddReceiverText(BTPair,
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<action android:name="android.bluetooth.device.action.BOND_BONDING" />
<action android:name="android.bluetooth.device.action.BOND_BONDED" />
<action android:name="android.bluetooth.device.action.BOND_STATE_CHANGED"/>
</intent-filter>)
Now the app reads an encrypted characteristic, and this triggers the pairing by the OS.
Depending of the results the app creates some buttons to control the device.
In Android 10 the service is not working, but looking for errors in an USB connected device with Android 10, I found this text:
B4X:
...
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
onCreate
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.broadcastreceiver.external.ExternalCommonBroadcastReceiver
onUidStateChanged: uid=10050, procState=11
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) } to com.samsung.android.app.watchmanagerstub/com.sec.android.applicationmgr.WMStubBroadCastReceiver
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) } to com.samsung.android.easysetup/.icmanager.IcBtStatusBroadcastReceiver
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) } to my.test.app/.btpair$btpair_BR
...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…