in AppRestrictions/Application/src/main/java/com/example/android/apprestrictions/CustomRestrictionsFragment.java [182:205]
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mBooleanPref) {
mBooleanEntry.setSelectedState((Boolean) newValue);
} else if (preference == mChoicePref) {
mChoiceEntry.setSelectedString((String) newValue);
} else if (preference == mMultiPref && newValue instanceof Set) {
// newValue is a Set<String>, skip the lint warning.
//noinspection unchecked
String[] selectedStrings = new String[((Set<String>) newValue).size()];
int i = 0;
//noinspection unchecked
for (String value : (Set<String>) newValue) {
selectedStrings[i++] = value;
}
mMultiEntry.setAllSelectedStrings(selectedStrings);
}
// Saves all the app restriction configuration changes from the custom activity.
Intent intent = new Intent(getActivity().getIntent());
intent.putParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS_LIST,
new ArrayList<>(mRestrictions));
getActivity().setResult(Activity.RESULT_OK, intent);
return true;
}