Prevent preferences fragment from crashing when resuming.
It was assuming there is always a priv ext preference. However, we remove the priv ext preference the first time the fragment is opened. In these circumstances, the preference no longer exists, resulting in a NPE.
This commit is contained in:
parent
05f6f08832
commit
5ef5288e3a
@ -215,6 +215,13 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
*/
|
*/
|
||||||
private void initPrivilegedInstallerPreference() {
|
private void initPrivilegedInstallerPreference() {
|
||||||
final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);
|
final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);
|
||||||
|
|
||||||
|
// This code will be run each time the activity is resumed, and so we may have already removed
|
||||||
|
// this preference.
|
||||||
|
if (pref == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Preferences p = Preferences.get();
|
Preferences p = Preferences.get();
|
||||||
boolean enabled = p.isPrivilegedInstallerEnabled();
|
boolean enabled = p.isPrivilegedInstallerEnabled();
|
||||||
boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity())
|
boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user