android - 在 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)
}
解决方案
推荐阅读
- algorithm - 如何在 m×n 矩阵中找到从 (1, 1) 到 (m, n) 的所有可能路径?
- java - mvn 依赖相同的版本和不同的 jars
- javascript - 如何在 fullpage.js 中自定义导航点?
- python - 使用 Flask 在 Python 中出现“无法导入名称”错误
- r - 您将如何表示自定义时区?一天的自定义时间范围?
- swift - Swift - 删除相交的线
- android - 未解决的参考:将数据绑定导入 MainActivity 时的数据绑定
- xamarin - 无法使用其输入参数初始化“XamarinDownloadArchives”任务
- php - 函数 wp_update_post() 为某些帖子返回 0
- julia - 为什么 Julia 开发人员将 `NA` 重命名为 `missing`