【发布时间】:2020-01-06 10:28:14
【问题描述】:
我们是否需要在创建通知通道之前检查它尚未创建?
private fun createChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// todo: add here check if channel is already created
val defaultChannel = NotificationChannel(MEDIA_UPLOAD_NOTIFICATION_CHANNEL_ID, MEDIA_UPLOAD_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH)
defaultChannel.description = MEDIA_UPLOAD_NOTIFICATION_CHANNEL_DESC
defaultChannel.enableVibration(true)
notificationManager.createNotificationChannel(defaultChannel)
}
}
【问题讨论】:
标签: java android kotlin push-notification android-notifications