Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current ringtone in Android?

I have found lots of examples how to get default ringtone. Something like that:

Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(),  alert);
         ringtone.setStreamType(AudioManager.STREAM_RING);
         ringtone.play();

But I want to get the actual current ringtone, that was set by the user.

like image 203
chabislav Avatar asked Mar 19 '14 10:03

chabislav


1 Answers

I was struggling with this issue as well, so the solution is:

Uri defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(getActivity().getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
Ringtone defaultRingtone = RingtoneManager.getRingtone(getActivity(), defaultRingtoneUri);
like image 197
dgabor Avatar answered Oct 05 '22 10:10

dgabor