Android: play default notification sound

9 03 2013

When aplication wants to notify user with sound, the best way to do it is to play notification sound that is set by the user on his device.

To do it, first you need to get Uri to that audio file from RingtoneManager. After that create a Ringtone object from that Uri and play it:

private void playDefaultNotificationSound() {
	Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
	Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);;

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!




One response

6 02 2015

Thanks exactly what I needed. Simple and usable

Give Your feedback:

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: