Skip to content

Commit

Permalink
targetSdk 34. foreground service type = dataSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Jul 15, 2024
1 parent 4fba7ce commit 038094f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
defaultConfig {
applicationId = "com.viliussutkus89.documenter"
minSdk = 21
targetSdk = 33
targetSdk = 34

versionCode = 130
versionName = "1.0.13"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-feature android:name="android.software.webview" android:required="true" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

<application
android:name=".DocumenterApplication"
Expand All @@ -28,11 +29,13 @@
<service
android:name=".background.pdf2htmlEXWorker$RemoteWorkerService"
android:exported="false"
android:foregroundServiceType="dataSync"
android:process=":pdf2htmlEXWorker" />

<service
android:name=".background.wvWareWorker$RemoteWorkerService"
android:exported="false"
android:foregroundServiceType="dataSync"
android:process=":wvWareWorker" />

<activity android:name=".ui.MainActivity" android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package com.viliussutkus89.documenter.background
import android.app.Notification
import android.app.NotificationManager
import android.content.Context
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.concurrent.futures.CallbackToFutureAdapter
Expand Down Expand Up @@ -74,7 +75,9 @@ abstract class ConverterWorkerCommon(ctx: Context, params: WorkerParameters): Re

override fun getForegroundInfoAsync(): ListenableFuture<ForegroundInfo?> {
return CallbackToFutureAdapter.getFuture {
it.set(ForegroundInfo(id.hashCode(), createNotification(applicationContext)))
it.set(ForegroundInfo(id.hashCode(), createNotification(applicationContext),
if (Build.VERSION.SDK_INT >= 29) FOREGROUND_SERVICE_TYPE_DATA_SYNC else 0
))
}
}

Expand Down

0 comments on commit 038094f

Please sign in to comment.