0

I saw the documentation:

public Uri sound

Added in API level 1
The sound to play.

To play the default notification sound, see defaults.

but how do I disable sound playing? sending Uri == null ?

Elad Benda
  • 35,076
  • 87
  • 265
  • 471

1 Answers1

2

If you don't call setSound(uri) with NotificationBuilder, the sound won't play. Eg. The following would play the default sound for notification:

Uri alarmSound = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this).setSmallIcon(R.drawable.ic_launcher)
                .setContentTitle("title")
                .setSound(alarmSound); 

Just remove ".setSound(alarmSound)" and it won't play the sound, like:

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this).setSmallIcon(R.drawable.ic_launcher)
                .setContentTitle("title");  

Hope i got the question right(?)

Pararth
  • 8,114
  • 4
  • 34
  • 51