List of usage examples for android.preference MultiSelectListPreference getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.xbmc.kore.ui.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); // Get the preference for side menu itens and change its Id to include // the current host MultiSelectListPreference sideMenuItens = (MultiSelectListPreference) findPreference( Settings.KEY_PREF_NAV_DRAWER_ITEMS); hostId = HostManager.getInstance(getActivity()).getHostInfo().getId(); sideMenuItens.setKey(Settings.getNavDrawerItemsPrefKey(hostId)); // HACK: After changing the key dinamically like above, we need to force the preference // to read its value. This can be done by calling onSetInitialValue, which is protected, // so, instead of subclassing MultiSelectListPreference and make it public, this little // hack changes its access mode. // Furthermore, only do this is nothing is saved yet on the shared preferences, // otherwise the defaults won't be applied if (getPreferenceManager().getSharedPreferences().getStringSet(Settings.getNavDrawerItemsPrefKey(hostId), null) != null) {// ww w. j a v a2s . com Class iterClass = sideMenuItens.getClass(); try { Method m = iterClass.getDeclaredMethod("onSetInitialValue", boolean.class, Object.class); m.setAccessible(true); m.invoke(sideMenuItens, true, null); } catch (Exception e) { } } // Check permission for phone state and set preference accordingly if (!hasPhonePermission()) { TwoStatePreference pauseCallPreference = (TwoStatePreference) findPreference( Settings.KEY_PREF_PAUSE_DURING_CALLS); pauseCallPreference.setChecked(false); } setupPreferences(); }