androidringtone

How to get Title of Ringtone with Uri


I try this:

Uri ringtoneUri = "content://media/internal/audio/media/55";
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
String name = ringtone.getTitle(context);

and I got result: name = 55, not a normal title like "common name"

I also saw Get the Ringtone title from RingtonePreference but there no accepted answer


Solution

  • try this

      Uri ringtoneUri = RingtoneManager
                    .getDefaultUri(RingtoneManager.TYPE_RINGTONE);
            Ringtone ringtone = RingtoneManager.getRingtone(this, ringtoneUri);
            String title = ringtone.getTitle(this);