Search code examples
androidaudiosharedpreferencesringtone

Setting sound for notification


How can I set sound for notification for my android application. In my application notification will be shown after 30 seconds. I want to give options for this alerts such as silent mode, vibration mode and an option to select from the available tones from the device. I am using the preference screen to show the settings menu. I want to to set the notification ring type application specific. Is there any way to establish this..


Solution

  • http://developer.android.com/reference/android/app/Notification.Builder.html#setSound(android.net.Uri)

    Notification.Builder.setSound();
    

    Use a ringtone preference in the preference activity to get the URI of the selected sound.