How to change notification sound by code in android?

前端 未结 4 1550
梦毁少年i
梦毁少年i 2020-12-10 17:27

Anyone knows how to change notification sound by code in android. I have managed to set the default ringtone, but cant find a way to set the notification tone...

I w

相关标签:
4条回答
  • 2020-12-10 17:34

    A good example of how to use the notification bar, configure sounds and leds can be found in this tutorial:

    http://www.firstdroid.com/2010/05/09/learn-by-example-using-notification-bar/

    Hope it helps, Adrian.

    0 讨论(0)
  • 2020-12-10 17:45

    here it is

    RingtoneManager.setActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION,      uriObjectofYourAudioFile);
    
    0 讨论(0)
  • 2020-12-10 17:47

    You can control this on a per-Notification basis via the sound field on Notification. Note that I haven't tried this personally, but it's what the docs say.

    0 讨论(0)
  • 2020-12-10 17:49

    This might be helpful

    notification.sound = Uri.parse("android.resource://com.packagename.org/raw/alert");
    
    0 讨论(0)
提交回复
热议问题