Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preferences_api, "save last location" causes crash #38

Open
jjblum opened this issue Mar 13, 2017 · 2 comments
Open

preferences_api, "save last location" causes crash #38

jjblum opened this issue Mar 13, 2017 · 2 comments
Labels

Comments

@jjblum
Copy link
Contributor

jjblum commented Mar 13, 2017

Changing the checkbox labeled "Save last location" causes the following crash:

AndroidRuntime [E] FATAL EXCEPTION: main AndroidRuntime [E] Process: com.platypus.android.tablet, PID: 5582 AndroidRuntime [E] java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String AndroidRuntime [E] at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:223) AndroidRuntime [E] at com.platypus.android.tablet.SettingsActivity.onSharedPreferenceChanged(SettingsActivity.java:83) AndroidRuntime [E] at android.app.SharedPreferencesImpl$EditorImpl.notifyListeners(SharedPreferencesImpl.java:476) AndroidRuntime [E] at android.app.SharedPreferencesImpl$EditorImpl.apply(SharedPreferencesImpl.java:384) AndroidRuntime [E] at android.preference.Preference.tryCommit(Preference.java:1404) AndroidRuntime [E] at android.preference.Preference.persistBoolean(Preference.java:1670) AndroidRuntime [E] at android.preference.TwoStatePreference.setChecked(TwoStatePreference.java:80) AndroidRuntime [E] at android.preference.TwoStatePreference.onClick(TwoStatePreference.java:65) AndroidRuntime [E] at android.preference.Preference.performClick(Preference.java:984) AndroidRuntime [E] at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:214) AndroidRuntime [E] at android.widget.AdapterView.performItemClick(AdapterView.java:305) AndroidRuntime [E] at android.widget.AbsListView.performItemClick(AbsListView.java:1160) AndroidRuntime [E] at android.widget.AbsListView$PerformClick.run(AbsListView.java:3067) AndroidRuntime [E] at android.widget.AbsListView$3.run(AbsListView.java:3862) AndroidRuntime [E] at android.os.Handler.handleCallback(Handler.java:739) AndroidRuntime [E] at android.os.Handler.dispatchMessage(Handler.java:95) AndroidRuntime [E] at android.os.Looper.loop(Looper.java:135) AndroidRuntime [E] at android.app.ActivityThread.main(ActivityThread.java:5466) AndroidRuntime [E] at java.lang.reflect.Method.invoke(Native Method) AndroidRuntime [E] at java.lang.reflect.Method.invoke(Method.java:372) AndroidRuntime [E] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984) AndroidRuntime [E] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

@jjblum jjblum added the bug label Mar 13, 2017
@jjblum
Copy link
Contributor Author

jjblum commented Mar 13, 2017

quick fix:

`

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
    Preference pref = findPreference(key);
    if (key.equalsIgnoreCase(KEY_PREF_SAVE_MAP))
    {
        boolean state = sharedPreferences.getBoolean(key, true);
        CheckBoxPreference cbpref = (CheckBoxPreference) pref;
        cbpref.setChecked(state);
    }
    else
    {
        pref.setSummary(sharedPreferences.getString(key,"default"));
    }
}   

`

@christomaszewski
Copy link
Member

Replicated on my setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants