fetch Available Ringtones - Android Phone

Android examples for Phone:Sound

Description

fetch Available Ringtones

Demo Code


//package com.java2s;
import android.content.Context;

import android.media.Ringtone;
import android.media.RingtoneManager;
import java.util.ArrayList;
import java.util.List;

public class Main {
    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));
        }/*from  w w  w. ja  v  a 2s . c om*/

        return ringtones;
    }
}

Related Tutorials