diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt index 7dfefd074..6ea53210d 100644 --- a/service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt @@ -5,6 +5,7 @@ import android.app.Service import android.content.Intent import android.os.PowerManager import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat import androidx.core.content.getSystemService import com.github.kr328.clash.common.compat.getColorCompat import com.github.kr328.clash.common.compat.pendingIntentFlags @@ -40,6 +41,8 @@ class DynamicNotificationModule(service: Service) : Module(service) { ) ) + private val notificationManager = NotificationManagerCompat.from(service) + private fun update() { val now = Clash.queryTrafficNow() val total = Clash.queryTrafficTotal() @@ -64,7 +67,7 @@ class DynamicNotificationModule(service: Service) : Module(service) { ) .build() - service.startForeground(R.id.nf_clash_status, notification) + notificationManager.notify(R.id.nf_clash_status, notification) } override suspend fun run() = coroutineScope { @@ -102,4 +105,4 @@ class DynamicNotificationModule(service: Service) : Module(service) { } } } -} \ No newline at end of file +}