Getting a list of available Android ringtones

I saw many examples of how to set the default ringtone, but I'm more interested in the ability to fill out a drop-down list filled with available ringtones on the phone. Thus, the list that people see when they change their ringtone in the Android settings, I want to be able to list all of them.

The closest thing I found is here , but again it's just for setting the default ringtone. Any ideas? It can be in or out of the ringtone.

+10
android drop-down-menu audio ringtone
source share
3 answers

RingtoneManager is what you are looking for. You just need to use setType to set TYPE_RINGTONE , and then iterate over the cursor provided by getCursor .

This is a working example of a hypothetical method that returns an array of URIs, with the only slight difference that it searches for alarms instead of ringtones:

RingtoneManager ringtoneMgr = new RingtoneManager(this); ringtoneMgr.setType(RingtoneManager.TYPE_ALARM); Cursor alarmsCursor = ringtoneMgr.getCursor(); int alarmsCount = alarmsCursor.getCount(); if (alarmsCount == 0 && !alarmsCursor.moveToFirst()) { return null; } Uri[] alarms = new Uri[alarmsCount]; while(!alarmsCursor.isAfterLast() && alarmsCursor.moveToNext()) { int currentPosition = alarmsCursor.getPosition(); alarms[currentPosition] = ringtoneMgr.getRingtoneUri(currentPosition); } alarmsCursor.close(); return alarms; 
+15
source share

This will return you the name and URI of all available ringtones. Do what you want with them!

 public Map<String, String> getNotifications() { RingtoneManager manager = new RingtoneManager(this); manager.setType(RingtoneManager.TYPE_RINGTONE); Cursor cursor = manager.getCursor(); Map<String, String> list = new HashMap<>(); while (cursor.moveToNext()) { String notificationTitle = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX); String notificationUri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX) + "/" + cursor.getString(RingtoneManager.ID_COLUMN_INDEX); list.put(notificationTitle, notificationUri); } return list; } 
+15
source share

I use an iphone phone with a boring default ringtone, I try to change my ringtone to the best and best ringtones that I like, every time the phone rings, my favorite ringtone is great

0
source share

All Articles