簡體   English   中英

如何在推送通知時禁用聲音?

[英]how to disable sound on push notification?

我看到了文檔

public Uri sound

Added in API level 1
The sound to play.

To play the default notification sound, see defaults.

但是如何禁用聲音播放? 發送Uri == null

如果不使用NotificationBuilder調用setSound(uri),則無法播放聲音。 例如。 以下內容將播放通知的默認聲音:

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

只需刪除“.setSound(alarmSound)”即可播放聲音,如:

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

希望我的問題正確(?)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM