From 384375d13faec8731e6ce17837d400a792221e5e Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:14:15 +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 --- app/src/main/java/io/legado/app/base/BaseService.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/base/BaseService.kt b/app/src/main/java/io/legado/app/base/BaseService.kt index 5a1dcf4b1..698a70505 100644 --- a/app/src/main/java/io/legado/app/base/BaseService.kt +++ b/app/src/main/java/io/legado/app/base/BaseService.kt @@ -21,6 +21,7 @@ import kotlin.coroutines.CoroutineContext abstract class BaseService : LifecycleService() { private val simpleName = this::class.simpleName.toString() + private var isForeground = false fun execute( scope: CoroutineScope = lifecycleScope, @@ -42,7 +43,10 @@ abstract class BaseService : LifecycleService() { LogUtils.d(simpleName) { "onStartCommand $intent ${intent?.toUri(0)}" } - startForegroundNotification() + if (!isForeground) { + startForegroundNotification() + isForeground = true + } return super.onStartCommand(intent, flags, startId) }