unable to set push notification sound in android

后端 未结 3 1040
-上瘾入骨i
-上瘾入骨i 2021-02-14 19:54

I have created the push notification application, I\'m getting the message from GCM services but push notification sound is not working. I need to play sound when I\'m getting n

相关标签:
3条回答
  • 2021-02-14 20:38

    I use the default notification sound. Maybe this will work:

    mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
    
    0 讨论(0)
  • 2021-02-14 20:49
    mBuilder.setDefaults(Notification.DEFAULT_SOUND)
    

    This worked for me, though the setDefaults() method does overwrite any vibration or LED light settings, so if you are wanting those as well you might have to set the sound directly. If default lights and/or vibration is fine you can bitwise OR the other static constants in Notification

    0 讨论(0)
  • 2021-02-14 20:51

    I use this code:

    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
    r.play();
    
    0 讨论(0)
提交回复
热议问题