Closed sakaijunsoccer closed 8 months ago
Sorry for the delayed response; I've been away from my PC in the past days. I'm happy that you enjoy the app - it's very meaningful to me.
I've noticed the app crashes on Android 14 due to a foreground service issue.
Here's how to fix it:
Add this line to your manifest:
<service android:name="androidx.work.impl.foreground.SystemForegroundService" android:foregroundServiceType="mediaPlayback" tools:node="merge" />
In the alarmWorker, stopwatchWorker, timerCompletedWorker, and TimerRunningWorker classes, update the foreground service type like this:
val foregroundInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ForegroundInfo(
...,
...,
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
)
} else {
ForegroundInfo(
...,
...,
)
}
For guidance, visit the "Add a foreground service type to a long-running worker" section : here If this solves the problem, please fork from the master branch, implement these changes, and submit a pull request. I'll make sure to add you as a contributor.
This app is amazing! Now, when I set this code to buid.gradle.kts with target sdk 34, I get the following error: In Android 14, it seems that I have to specify FOREGROUND_SERVICE and tags in AndroidManifest.xml, but I don't know which service name to specify. Is it possible for you to let me know if you don't mind?