Example usage for android.media RingtoneManager getRingtone

List of usage examples for android.media RingtoneManager getRingtone

Introduction

In this page you can find the example usage for android.media RingtoneManager getRingtone.

Prototype

public Ringtone getRingtone(int position) 

Source Link

Document

Gets a Ringtone for the ringtone at the given position in the Cursor .

Usage

From source file:Main.java

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 ww w.  j a  v a  2 s. co m

    return ringtones;
}

From source file:Main.java

public static List<Ringtone> fetchAvailableRingtones(Context context) {
    List<Ringtone> ringtones = new ArrayList<>();
    RingtoneManager ringtoneManager = new RingtoneManager(context);
    ringtoneManager.setType(RingtoneManager.TYPE_RINGTONE);

    int count = ringtoneManager.getCursor().getCount();

    for (int i = 0; i < count; i++) {
        ringtones.add(ringtoneManager.getRingtone(i));
    } // END for/*from  w  ww.  ja  va  2s  .com*/

    return ringtones;
}