首选项铃声默认值

时间:2011-10-03 12:03:48

标签: android preference ringtone

我在偏好.xml

中有这个
        <RingtonePreference android:key="ringtone_uri"
            android:title="@string/preferences_select_ringtone"
            android:showDefault="true" android:srinlent="true"
            android:summary="@string/preferences_select_ringtone_summary" />

每当我第一次开始全新安装应用程序时,默认值为silent :(当我点击铃声首选项时,对话框打开,默认选择默认。我默认需要“默认铃声”来被选中。我该怎么做 enter image description here

我怎样才能将默认值设置为“默认铃声”而不是静音,我不知道为什么这个默认为我的默认我没有在我的代码中设置任何地方,默认是android系统的默认值。 ..

3 个答案:

答案 0 :(得分:7)

将默认值设置为默认铃声的最简单方法

<RingtonePreference
        android:showDefault="true"
        android:showSilent="true"
        android:defaultValue="content://settings/system/notification_sound"
                    .......
        >
</RingtonePreference>

答案 1 :(得分:5)

我正在搜索如何设置铃声的默认值,并意识到当未设置首选项时,值为空并且默认选择静默。但我这样做

defaultstr = Uri.parse(PreferenceManager.getDefaultSharedPreferences(context).getString("r_uri",
    android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString()));
//than I do this, I save the default ringtone to my setting
 if (defaultstr.equals(android.provider.Settings.System.DEFAULT_RINGTONE_URI)) {
    PreferenceManager.getDefaultSharedPreferences(context).edit().putString("r_uri",
        android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString()).commit();
}

我希望这会对别人有所帮助。顺便说一下,我发现这个变通办法,而且我已经把头埋了好几个小时

答案 2 :(得分:1)

只需停用“无声”项:

<RingtonePreference android:key="ringtone_uri"
            android:title="@string/preferences_select_ringtone"
            android:showDefault="true" android:srinlent="true"
            android:summary="@string/preferences_select_ringtone_summary" 
            android:showSilent="false">
相关问题