Camera Shutter Sound can't restore to default

Launch Camera --> check shutter sound default status is "OFF" --> set the shutter sound status to "ON" --> click the restore to default button --> the shutter sound status isn't the default value "OFF"

 

As the customization and the value of SDMID isn't "on" or "off",so I must translate it in the java code. But the preference.xml has the definition (KEY_SHUTTER_SOUND),and the default value is this:

<ListPreference 
    camera:key = "pref_camera_shutter_sound"
    camera:defaultValue="@string/pref_camera_shutter_sound_default"
    ...
/>

If I don't deal with it,the default value isn't via customization but

camera:defaultValue="@string/pref_camera_shutter_sound_default"

So I set the shutter sound default value in the method restorePreferences()  in the CameraSettings.java manually.I add a function:

private static void setShutterSoundDefault() {

      SharedPreferences.Editor editor = preferences.edit();

      editor.putString(KEY_SHUTTER_SOUND,shutterValue);

      editor.apply();

} 

and  add it end of the restorePreference().The shutterValue is from SDM which you want to custom,not 

camera:defaultValue="@string/pref_camera_shutter_sound_default"

OK,it can work now.

你可能感兴趣的:(Camera Shutter Sound can't restore to default)