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) }