Is there a way to add a default value in a RingtonePreference, via XML? For example, here's what my preference.xml looks like.
<RingtonePreference android:key="alarm"
android:title="Alarm" android:name="Alarm"
android:summary="Select an alarm"
android:ringtoneType="alarm" android:showDefault="true" />
If possible, I'd like to set the RingtonePreference to the default ringtone, like this:
<RingtonePreference android:key="alarm"
android:title="Alarm" android:name="Alarm"
android:summary="Select an alarm"
android:ringtoneType="alarm" android:showDefault="true"
android:defaultValue="defaultRingtone" />
You can define the default in the XML. As you said, it needs a URI. Simply put the default URI for what you need. For example, for a default alarm sound you would put:
<RingtonePreference android:key="alarm"
android:title="Alarm" android:name="Alarm"
android:summary="Select an alarm"
android:ringtoneType="alarm" android:showDefault="true"
android:defaultValue="content://settings/system/alarm_alert" />
For a notification you would put:
android:defaultValue="content://settings/system/notification_sound"
Etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With