From 0ea595692ffe46ea1935e3fa53388d955ef3bab2 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 23 Feb 2024 11:18:43 -0800 Subject: [PATCH] Foreground Permission Reset As of Android 13 we need to request a permission to stay in the background https://developer.android.com/develop/background-work/background-tasks/persistent/how-to/long-running --- android/app/src/main/AndroidManifest.xml | 11 +++++++++-- .../src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6c9df750..a7f8e23c 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + - + + + diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index f6429989..f9e05bec 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -11,6 +11,7 @@ import android.graphics.Color import android.net.Uri import android.os.Build import android.util.Log +import android.content.pm.ServiceInfo import androidx.annotation.RequiresApi import androidx.core.app.NotificationCompat import androidx.localbroadcastmanager.content.LocalBroadcastManager @@ -292,7 +293,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : .addAction(android.R.drawable.ic_delete, cancel, PendingIntent.getActivity(applicationContext, 2, cancelIntent, flags)) .build() - return ForegroundInfo(101, notification) + return ForegroundInfo(101, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC) } @RequiresApi(Build.VERSION_CODES.O)