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 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

        return ringtones;
    }
}