Skip to content

Commit

Permalink
Fixed foreground service changes in Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
spacecowboy committed Apr 19, 2024
1 parent 8d87a2a commit cd1d3df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="internalOnly">
<!-- Import export feeds -->
<uses-permission
Expand All @@ -13,6 +14,8 @@
<!-- To limit syncing to only WiFi -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- For expedited work manager jobs that run in foreground service -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>

<permission
android:name="${applicationId}.permission.read"
Expand Down Expand Up @@ -195,5 +198,11 @@
android:authorities="${applicationId}.rssprovider"
android:exported="true"
android:readPermission="${applicationId}.permission.read" />

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ private fun createNotificationChannel(
notificationManager.createNotificationChannel(channel)
}

/**
* Necessary for expedited work.
* Pre Android 12 they will run as foreground services, but on Android 12+ they will run as expedited Jobs.
*/
fun createForegroundInfo(
context: Context,
notificationManager: NotificationManagerCompat,
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencyResolutionManagement {
version("qrgen", "2.6.0")
version("androidxCore", "1.10.1")
version("androidxTestcore", "1.5.0")
version("workmanager", "2.8.1")
version("workmanager", "2.9.0")
version("appcompat", "1.6.1")
version("material", "1.6.1")
version("preference", "1.2.1")
Expand Down

0 comments on commit cd1d3df

Please sign in to comment.