0

我想获取手机铃声,但只能看到英文(非本地化版本)。

我的理论是使用 ContextWrapper,并将该上下文语言环境设置为en_US并将该新语言环境传递给RingtoneManager.getRingtone()(基于以编程方式设置语言环境的代码):

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

所以,是的,这不能按预期工作。有任何想法吗?

4

1 回答 1

0

希望您通过以下代码片段找到您正在寻找的内容:

        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")
于 2019-06-24T09:11:48.777 回答