语言

NotificationChannel.SetSound(Uri, AudioAttributes) 方法

定义

设置应为发布到此通道及其音频属性的通知播放的声音。

[Android.Runtime.Register("setSound", "(Landroid/net/Uri;Landroid/media/AudioAttributes;)V", "", ApiSince=26)]
public void SetSound(Android.Net.Uri? sound, Android.Media.AudioAttributes? audioAttributes);
[<Android.Runtime.Register("setSound", "(Landroid/net/Uri;Landroid/media/AudioAttributes;)V", "", ApiSince=26)>]
member this.SetSound : Android.Net.Uri * Android.Media.AudioAttributes -> unit

参数

sound
Uri

Uri

audioAttributes
AudioAttributes

AudioAttributes

特性

注解

设置应为发布到此通道及其音频属性的通知播放的声音。 至少具有NotificationManager.IMPORTANCE_DEFAULT重要性的通知通道应该有声音。 注意:可以在 Uri 参数中提供特定于应用的声音,但由于通道在应用安装期间持久且已备份和还原,因此 URI 应稳定。 因此,不建议使用ContentResolver.SCHEME_ANDROID_RESOURCE URI,因为资源 ID 可以在应用升级时更改。 仅在通道提交到 NotificationManager.createNotificationChannel(NotificationChannel)之前可修改。

Android 参考。android.app.NotificationChannel.setSound

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于