Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I insert a android:defaultValue trait for RingtonePreference, via XML?

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" />
like image 819
Japtar Avatar asked Nov 20 '10 21:11

Japtar


1 Answers

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.

like image 71
IncrediApp Avatar answered Sep 30 '22 04:09

IncrediApp