Android disable notification sounds

前端 未结 3 585
猫巷女王i
猫巷女王i 2021-01-20 00:47

I want to create a notification without any sounds. How can I do this? I tried the code below but it\'s not working for me:

notification = mBuilder
        .         


        
3条回答
  •  走了就别回头了
    2021-01-20 01:12

    You can create the NotificationCompat.Builder object without using setSound(). This will create a notification without any sound.

    notification = mBuilder
                    .setStyle(notiStyle)
                    .setSmallIcon(notificationIcon)
                    .setTicker(title)
                    .setWhen(0)
                    .setAutoCancel(true)
                    .setContentTitle(title)
                    .setContentIntent(resultPendingIntent)
                    .build();
    

提交回复
热议问题