Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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));
        }

        return ringtones;
    }
}