简体   繁体   中英

Get ringtone - english name

I want to get the ringtones of a phone, but see only the english (non-localized version).

My theory, was using a ContextWrapper, and set that context locale to en_US and pass that new locale to RingtoneManager.getRingtone() (code based from Set Locale programmatically ):

ContextWrapper cw = new ContextWrapper(context);
Context cc = setContextLocale(cw, "en_US"); // This method was copied from the StackOverflow question above ^^
Ringtone defaultRingtone = RingtoneManager.getRingtone(cc,  Settings.System.DEFAULT_RINGTONE_URI);
String sss = defaultRingtone.getTitle(cc);

So, yes, this does not work as expected. Any ideas?

Hope you find what you are looking for with following code snippet:

        data class Ringtone(
            val _id: String,
            val title: String
        )
        val cursor = RingtoneManager(this).cursor
        cursor.moveToFirst()
        val list = ArrayList<Ringtone>()
        do {
            list.add(Ringtone(
                cursor.getString(0),
                cursor.getString(1)
            ))
        } while (cursor.moveToNext())
        Log.i(TAG, "ringtones list=$list")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM