My app allows users to customize ringtones for both calls and notifications. It achieves this by setting the default ringtone using the following code:
Calls:
RingtoneManager.setActualDefaultRingtoneUri(myContext, RingtoneManager.TYPE_RINGTONE, uri);
Notifications:
RingtoneManager.setActualDefaultRingtoneUri(myContext, RingtoneManager.TYPE_NOTIFICATION, anotherUri);
While this approach works well on most devices, I’ve received reports from some users with Samsung phones specifically (specially S24 using Android 14). The app successfully changes the call ringtone, but not the default notification ringtone.
When it fails, it shows this exception:
java.lang.IllegalArgumentException: You cannot keep your settings in the secure settings.
I have tried using stock-built-in ringtones as well as external mp3 files. All seems to work for TYPE_RINGTONE but not for TYPE_NOTIFICATION.
Can anyone help with this?