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