从默认铃声中获取元数据

时间:2011-12-03 16:30:23

标签: android

我有特定声音文件的URI,默认铃声contents://settings/system/ringtone。我怎么能得到那首歌的标题和其他细节?

1 个答案:

答案 0 :(得分:5)

获取默认铃声元数据比您想象的要复杂一点。

一个好的起点是RingtoneManager课程。它提供了从四个区域获取默认Ringtone的方法:

int    TYPE_ALARM           Type that refers to sounds that are used for the alarm.
int    TYPE_ALL             All types of sounds.
int    TYPE_NOTIFICATION    Type that refers to sounds that are used for notifications.
int    TYPE_RINGTONE        Type that refers to sounds that are used for the phone ringer.

使用此类可以直接获得默认铃声的标题:

Uri ringtoneUri = RingtoneManager
        .getDefaultUri(RingtoneManager.TYPE_RINGTONE);
Ringtone ringtone = RingtoneManager.getRingtone(this, ringtoneUri);
String title = ringtone.getTitle(this);

我不确定是否有可能获得有关铃声的其他数据。

相关问题