0

I want to post my notification with priority hight and no sound or vibration is needed. I don't even call setSound() or setVibrate(), however, I will always get the default sound and vibrate with my notification. Any advice?

notificationBuilder = NotificationCompat.Builder(context, NotificationKeys.CHANNEL_NEW_ORDER_ID)
            .setContentIntent(pendingIntent)
            .setContentTitle(context.getString(R.string.app_name))
            .setCustomContentView(collapseView)
            .setStyle(NotificationCompat.DecoratedCustomViewStyle())
            .setSmallIcon(R.drawable.ic_app_logo_primary)
            .setFullScreenIntent(pendingIntent, true)
            .setOnlyAlertOnce(true)
            .setOngoing(true)
            .setAutoCancel(true)
            // I also tried with null but didn't work
            .setSound(null)
            .setVibrate(null)

NotificationManagerCompat.from(context).notify(myNotificationKey, notificationBuilder.build())
Master Zzzing
  • 524
  • 6
  • 18
  • 1
    Please Go through - https://stackoverflow.com/questions/46079067/how-to-stop-playing-notification-sound-programmatically-on-android?rq=1 And https://stackoverflow.com/questions/48453189/disable-notification-sound-on-android-o may it will help you out – Nikhat Shaikh Oct 17 '19 at 04:50
  • I have it fixed. Thank you so much – Master Zzzing Oct 17 '19 at 05:04

1 Answers1

0

Please Use NotificationManagerCompat.from(this).cancelAll() for clear all notification on banner. and Please go Disable notification sound on Android O for desable the sound of notification.

Avinash
  • 867
  • 4
  • 11