Get the Ringtone title from RingtonePreference
Asked Answered
H

1

16

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?

Hedi answered 21/12, 2010 at 10:30 Comment(0)
N
69
Uri ringtoneUri = Uri.parse(strRingtonePreference);
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
String name = ringtone.getTitle(context);
Nalor answered 16/2, 2011 at 13:51 Comment(3)
how can i set ring tone name as a summery of RingTonePreference?Indigo
i got id of ringtone insted of nameVaughan
I also get ringtone id instead of display name/titleGillette

© 2022 - 2024 — McMap. All rights reserved.