我想要
我是机器人的菜鸟。
我的应用程序显示提示通知。现在,我的应用程序总是在它听通知的时候响,而不管它是开/关还是无声模式。
我想做下一件事。
禁用通知声音,并在静默模式下保持提示。
谢谢你的帮助。
问题
当我的应用程序响的时候静默模式。
代码
MainActivity.kt
val channel = NotificationChannel(
notificationType.channelId,
notificationType.channelName,
NotificationManager.IMPORTANCE_HIGH
).apply {
setSound(uri, attribute)
enableVibration(true)
vibrationPattern = createVibrate()
lightColor = Color.BLUE
}
channel.lockscreenVisibNotification.VISIBILITY_PUBLIC
manager.createNotificationChannel(channel)PushNotificationListenerService.kt
val notificationBuilder = NotificationComBuilder(this, receivedChannelId)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(R.drawable.ic_menu_logo)
.setContentIntent(pendingIntent)
.setPriority(PRIORITY_MAX)
.setCategory(CATEGORY_CALL)
.setSound(defaultSoundUri)
.setVibrate(createVibrate())
.setAutoCancel(true)
.setLights(Color.BLUE, 5000, 10)我试过的东西
setSound设置。(这不起作用)notificationBuilder.setSilent(true)。(提示已删除通知。)NotificationManager.IMPORTANCE_HIGH更改为IMPORTANCE_LOW。(提示已删除通知)其他信息
版本
kotlin_version = "1.4.32"
navigation_version = "2.3.5"
activity_version = "1.2.3"
fragment_version = "1.3.6"
compileSdkVersion 29
buildToolsVersion "30.0.3"
minSdkVersion 21
targetSdkVersion 29
kotlinOptions {
jvmTarget = '1.8'
}设计版本
devise name: AQUOS sense4 basic
devise android version: 10设计通知设置
all ON发布于 2021-09-22 02:34:31
发布于 2021-09-21 07:50:27
channel.setSound(null, null);将禁用通知的声音。
https://stackoverflow.com/questions/69263543
复制相似问题