From 0f0b7b89a26bea21eb088a631796813ce9aa2ce5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 29 Jul 2023 22:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/ExportBookService.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/ExportBookService.kt b/app/src/main/java/io/legado/app/service/ExportBookService.kt index 8ecf9169c..483022389 100644 --- a/app/src/main/java/io/legado/app/service/ExportBookService.kt +++ b/app/src/main/java/io/legado/app/service/ExportBookService.kt @@ -4,6 +4,7 @@ import android.content.Intent import android.graphics.Bitmap import android.graphics.drawable.Drawable import android.net.Uri +import android.os.Build import android.util.ArraySet import androidx.core.app.NotificationCompat import androidx.documentfile.provider.DocumentFile @@ -134,6 +135,12 @@ class ExportBookService : BaseService() { servicePendingIntent(IntentAction.stop) ) } else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + stopForeground(STOP_FOREGROUND_DETACH) + } else { + @Suppress("DEPRECATION") + stopForeground(false) + } notification.setOngoing(false) notification.setDeleteIntent( servicePendingIntent(IntentAction.stop) @@ -342,7 +349,13 @@ class ExportBookService : BaseService() { */ private fun paresScope(scope: String): IntArray { val split = scope.split(",") - val result = ArraySet() + + @Suppress("RemoveExplicitTypeArguments") + val result = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + ArraySet() + } else { + HashSet() + } for (s in split) { val v = s.split("-") if (v.size != 2) {