首页 > 解决方案 > 在 Android 11 中的删除通知通道中崩溃,有时也在 android 10 中

问题描述

Fatal Exception: java.lang.SecurityException: Not allowed to delete channel 1250012 with a foreground service

我的代码在这里

val notificationMgnr =
                application.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                notificationMgnr.deleteNotificationChannel(CHANNEL_ID)
            }

标签: androidandroid-serviceandroid-notificationsandroid-11android-notification.mediastyle

解决方案


推荐阅读