Get the Ringtone title from RingtonePreference

邮差的信 提交于 2021-02-07 04:59:25

问题


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?


回答1:


Uri ringtoneUri = Uri.parse(strRingtonePreference);
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
String name = ringtone.getTitle(context);


来源:https://stackoverflow.com/questions/4498315/get-the-ringtone-title-from-ringtonepreference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!