List of usage examples for android.content RestrictionEntry setAllSelectedStrings
public void setAllSelectedStrings(String[] allSelectedStrings)
From source file:com.android.tv.settings.users.AppRestrictionsFragment.java
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String key = preference.getKey(); if (key != null && key.contains(DELIMITER)) { StringTokenizer st = new StringTokenizer(key, DELIMITER); final String packageName = st.nextToken(); final String restrictionKey = st.nextToken(); AppRestrictionsPreference appPref = (AppRestrictionsPreference) mAppList .findPreference(getKeyForPackage(packageName)); ArrayList<RestrictionEntry> restrictions = appPref.getRestrictions(); if (restrictions != null) { for (RestrictionEntry entry : restrictions) { if (entry.getKey().equals(restrictionKey)) { switch (entry.getType()) { case RestrictionEntry.TYPE_BOOLEAN: entry.setSelectedState((Boolean) newValue); break; case RestrictionEntry.TYPE_CHOICE: case RestrictionEntry.TYPE_CHOICE_LEVEL: ListPreference listPref = (ListPreference) preference; entry.setSelectedString((String) newValue); String readable = findInArray(entry.getChoiceEntries(), entry.getChoiceValues(), (String) newValue); listPref.setSummary(readable); break; case RestrictionEntry.TYPE_MULTI_SELECT: Set<String> set = (Set<String>) newValue; String[] selectedValues = new String[set.size()]; set.toArray(selectedValues); entry.setAllSelectedStrings(selectedValues); break; default: continue; }/*from ww w. jav a2 s . c o m*/ mUserManager.setApplicationRestrictions(packageName, RestrictionsManager.convertRestrictionsToBundle(restrictions), mUser); break; } } } } return true; }