Question

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?

Was it helpful?

Solution

Uri ringtoneUri = Uri.parse(strRingtonePreference);
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
String name = ringtone.getTitle(context);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top