Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the Ringtone title from RingtonePreference

I have a RingtonePreference that is used to select a ringtone that is broadcasted to a receiver used in an Alarm application.
I would like to display the title (the titles displayed in the list you see when you choose the ringtone) of the selected ringtone in the summary of the RingtonePrefernce. Somehow get the ID3 tag? Some ringtones would be mp3 but not all so this might not be a good idea?

What I do now is:

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
strRingtonePreference = prefs.getString("RingtonePref", "DEFAULT_RINGTONE_URI");

This will make strRingtonePreference look like "content://media/internal/audio/media/55" which is not very informative to the user.

How can I do this?

like image 840
Alex Bergsland Avatar asked Dec 21 '10 10:12

Alex Bergsland


1 Answers

Uri ringtoneUri = Uri.parse(strRingtonePreference);
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
String name = ringtone.getTitle(context);
like image 108
Dan Dyer Avatar answered Oct 01 '22 23:10

Dan Dyer