diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index a578bab15..782acb2b9 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -90,38 +90,35 @@ class App : MultiDexApplication() { @RequiresApi(Build.VERSION_CODES.O) private fun createChannelId() { (getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager)?.let { - //用唯一的ID创建渠道对象 val downloadChannel = NotificationChannel( channelIdDownload, getString(R.string.action_download), NotificationManager.IMPORTANCE_LOW - ) - //初始化channel - downloadChannel.enableLights(false) - downloadChannel.enableVibration(false) - downloadChannel.setSound(null, null) + ).apply { + enableLights(false) + enableVibration(false) + setSound(null, null) + } - //用唯一的ID创建渠道对象 val readAloudChannel = NotificationChannel( channelIdReadAloud, getString(R.string.read_aloud), NotificationManager.IMPORTANCE_LOW - ) - //初始化channel - readAloudChannel.enableLights(false) - readAloudChannel.enableVibration(false) - readAloudChannel.setSound(null, null) + ).apply { + enableLights(false) + enableVibration(false) + setSound(null, null) + } - //用唯一的ID创建渠道对象 val webChannel = NotificationChannel( channelIdWeb, getString(R.string.web_service), NotificationManager.IMPORTANCE_LOW - ) - //初始化channel - webChannel.enableLights(false) - webChannel.enableVibration(false) - webChannel.setSound(null, null) + ).apply { + enableLights(false) + enableVibration(false) + setSound(null, null) + } //向notification manager 提交channel it.createNotificationChannels(listOf(downloadChannel, readAloudChannel, webChannel))