Number instead of ringtone name

I want to get the name of the ringtone. I am using this code

Ringtone ringtone = RingtoneManager.getRingtone(preference.getContext(), Uri.parse(stringValue)); String name = ringtone.getTitle(preference.getContext()); 

And I get the number (e.g. 17090), not the name of the ringtone. What's wrong?

+5
source share
2 answers

I had the same problem with the latest versions of Android (4.4). There should be a problem with getTitle () and external storage, as it works fine on internal storage. I also found that read access would also work. This may be less invasive for users.

 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
+2
source

I have found the answer. I added:

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

and now it works!

But why is this permission necessary?

+2
source

Source: https://habr.com/ru/post/1200214/


All Articles