我想
。我是安卓的新手。
我的應用程式顯示抬頭通知。 現在,我的應用程式總是在聽取通知時響起,而不管靜音模式的開啟/關閉。
我想做下一件事。
禁用通知聲音。
在保持靜音模式下的抬頭通知時,禁用通知聲音。
謝謝你的幫助。
問題是
。我的應用程式在靜音模式下響起。
我的應用程式在靜音模式下響起。
代碼
MainActivity.kt
val channel = NotificationChannel(
notificationType.channelId,
notificationType.channelId, notificationType.channelName,
通知Manager.IMPORTANCE_HIGH
).apply {
setSound(uri, attribute)
enableVibration(true)
vibrationPattern = createVibrate()
lightColor = Color.BLUE
}
channel.lockkscreenVisibNotification.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)。(抬頭通知被洗掉。)notificationBuilder.setSilent(true)。
NotificationManager.importance_HIGH改為importance_LOW。(抬頭通知已被洗掉。)其他資訊
版本。kotlin_version = "1.4.32"
navigation_version = "2.3.5"/span>
activity_version = "1.2.3"/span>
fragment_version = "1.3.6"/span>
編譯SdkV版本 29
buildToolsVersion "30.0.3"/span>
minSdkV版本 21
targetSdkV版本 29
kotlinOptions {
jvmTarget = '1.8
}
devise版本
devise name: AQUOS sense4 basic
devise android版本: 10
devise通知設定
。all ON
uj5u.com熱心網友回復:
channel.setSound(null, null)。
將禁用通知的聲音
uj5u.com熱心網友回復:我通過https://stackoverflow.com/a/54785422/14019506
解決了這個問題。感謝DeePanShu。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/332811.html
標籤:
