You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using the backgroundsensors library in my Android project, and I've encountered an issue when running the app on devices with Android 14 (SDK 34). The issue occurs when trying to start a foreground service using BaseSensorRecordingService.
Issue:
Starting from Android 14, the system requires foreground services to specify a foregroundServiceType when calling startForeground. However, it appears that the BaseSensorRecordingService does not include this type when it starts the foreground service, resulting in the following exception:
java.lang.RuntimeException: Unable to create service es.uji.geotec.backgroundsensors.service.BaseSensorRecordingService: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{d9c7d10 8482:com.example.phone2/u0a199} targetSDK=34
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4989)
...
Caused by: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{d9c7d10 8482:com.example.phone2/u0a199} targetSDK=34
at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
...
Steps to Reproduce:
Use BaseSensorRecordingService to start a foreground service on a device running Android 14.
Observe the MissingForegroundServiceTypeException being thrown.
Proposed Solution:
Modify the runInForegroundWithNotification method in BaseSensorRecordingService to include the foregroundServiceType parameter when calling startForeground, as shown below:
Hi @Mustafa-raja, thank you for reporting this issue and the proposed solution. I'm currently working on solving this issue and releasing a new version of the library. I'll keep you posted!
Hi @Mustafa-raja, I've released the v1.4.0 of the library supporting Android 14. Therefore, after updating to the new version, everything should work as expected. Take in mind that the indexing of new releases might take a while (it should be available in a couple of hours).
Please, tell me if everything works fine once you update to the new version to close the issue.
I'm currently using the backgroundsensors library in my Android project, and I've encountered an issue when running the app on devices with Android 14 (SDK 34). The issue occurs when trying to start a foreground service using BaseSensorRecordingService.
Issue:
Starting from Android 14, the system requires foreground services to specify a foregroundServiceType when calling startForeground. However, it appears that the BaseSensorRecordingService does not include this type when it starts the foreground service, resulting in the following exception:
Steps to Reproduce:
Proposed Solution:
Modify the
runInForegroundWithNotification
method inBaseSensorRecordingService
to include theforegroundServiceType
parameter when callingstartForeground
, as shown below:This would ensure compatibility with Android 14 and prevent the
MissingForegroundServiceTypeException
.The text was updated successfully, but these errors were encountered: