0

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?

Selman Tosun
  • 428
  • 5
  • 14
elcuco
  • 8,948
  • 9
  • 47
  • 69
  • I don't ringtone names are localizes when I change system language. I'm using emulator with Android 9.0 for testing. Do you see those ringtones localized? If yes which device and which Android version do you have – Dmytro Batyuk Jun 24 '19 at 08:35
  • On Pixel2 (emulator) ringtones are not translated (funny, settings crashes), however on Pixel3 (real HW) I can see the ringtones translated. I am unable to find in the settings code where those translations come from. Again, funny. – elcuco Jun 24 '19 at 09:05

1 Answers1

0

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")
Dmytro Batyuk
  • 957
  • 8
  • 15