Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.Activity;

import android.database.Cursor;

import android.media.RingtoneManager;
import android.net.Uri;

import java.util.LinkedHashMap;
import java.util.Map;

public class Main {
    public static Map<String, Uri> getRingtones(Activity activity) {
        RingtoneManager manager = new RingtoneManager(activity);
        manager.setType(RingtoneManager.TYPE_RINGTONE);
        Cursor cursor = manager.getCursor();

        Map<String, Uri> list = new LinkedHashMap<>();
        while (cursor.moveToNext()) {
            String notificationTitle = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
            Uri notificationUri = manager.getRingtoneUri(cursor.getPosition());

            list.put(notificationTitle, notificationUri);
        }

        return list;
    }
}