Share via


NotificationChannel.SetSound(Uri, AudioAttributes) Method

Definition

Sets the sound that should be played for notifications posted to this channel and its audio attributes.

[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

Parameters

sound
Uri
audioAttributes
AudioAttributes
Attributes

Remarks

Sets the sound that should be played for notifications posted to this channel and its audio attributes. Notification channels with an #getImportance() importance of at least NotificationManager#IMPORTANCE_DEFAULT should have a sound.

Note: An app-specific sound can be provided in the Uri parameter, but because channels are persistent for the duration of the app install, and are backed up and restored, the Uri should be stable. For this reason it is not recommended to use a ContentResolver#SCHEME_ANDROID_RESOURCE uri, as resource ids can change on app upgrade.

Only modifiable before the channel is submitted to NotificationManager#createNotificationChannel(NotificationChannel).

Java documentation for android.app.NotificationChannel.setSound(android.net.Uri, android.media.AudioAttributes).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to