我正在使用RingtoneManager
来获取铃声,它会返回所有铃声,包括系统铃声。我怎样才能获取存储在SD卡上但不是系统默认铃声的铃声?
这是我的铃声提取器类的代码
public class RingtoneHelper {
public static List<Ringtone> fetchAvailableRingtones(Context context){
List<Ringtone> ringtones = new ArrayList<>();
RingtoneManager mgr = new RingtoneManager(context);
mgr.setType(RingtoneManager.TYPE_RINGTONE);
int n = mgr.getCursor().getCount();
for(int i=0;i<n;i++){
ringtones.add(mgr.getRingtone(i));
}
return ringtones;
}
public static void changeRingtone(Context context){
SharedPreferences preferences = context.getSharedPreferences("randomizer", Context.MODE_PRIVATE);
if(!preferences.getBoolean("active", false))
return;
RingtoneManager mgr = new RingtoneManager(context);
Random random = new Random(System.currentTimeMillis());
int n = random.nextInt(mgr.getCursor().getCount());
RingtoneManager.setActualDefaultRingtoneUri(context,
RingtoneManager.TYPE_RINGTONE, mgr.getRingtoneUri(n));
}
}