How to show a notification without a sound java

后端 未结 11 1697
鱼传尺愫
鱼传尺愫 2020-12-11 15:09

How can I make a notification that doesn\'t make a sound when I build it? I am building a notification, and my users don\'t like the fact that it makes a sound.

11条回答
  •  北海茫月
    2020-12-11 15:37

    Use this If you want all (sound, vibration and lights) in notifications.

    builder.setDefaults(Notification.DEFAULT_ALL);
    

    Or you can enable or disable items based on your requirements.

    builder.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
    

    comment this line if you want nothing.

提交回复
热议问题