<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Notifications">
<CheckBoxPreference
android:key="vibration"
android:title="Vibrate"
android:summary="Vibrate phone for notifications" />
<CheckBoxPreference
android:key="play_tone"
android:title="Play Ringtone"
android:summary="Play Ringtone for notifications" />
<RingtonePreference
android:key="app_ringtone"
android:dependency="play_tone"
android:title="Select Ringtone"
android:ringtoneType="notification"
android:showDefault="true"
android:shouldDisableView="true"
android:summary="Pick a Ringtone" />
</PreferenceCategory>
</PreferenceScreen>
这是我的偏好xml。但,
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.getString("app_ringtone", null);
总是返回 null。我正在设备上调试(HTC Wildfire)。