Hi all,

I have an app, Quaker, in which the preference activity force closes. On the
emulator the activity opens but when you try to use any of the options it
force closes. On my device the app force closes when you select preferences
from the options menu. The device log is:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.raghavsood.quaker/com.raghavsood.quaker.Preferences}:
java.lang.ClassCastException: java.lang.Integer
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: java.lang.Integer
at
android.app.ContextImpl$SharedPreferencesImpl.getString(ContextImpl.java:2754)
at android.preference.Preference.getPersistedString(Preference.java:1269)
at
android.preference.ListPreference.onSetInitialValue(ListPreference.java:232)
at
android.preference.Preference.dispatchSetInitialValue(Preference.java:1192)
at android.preference.Preference.onAttachedToHierarchy(Preference.java:1004)
at
android.preference.PreferenceGroup.addPreference(PreferenceGroup.java:156)
at
android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:97)
at
android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:38)
at android.preference.GenericInflater.rInflate(GenericInflater.java:488)
at android.preference.GenericInflater.inflate(GenericInflater.java:326)
at android.preference.GenericInflater.inflate(GenericInflater.java:263)
at
android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
at
android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:262)
at com.raghavsood.quaker.Preferences.onCreate(Preferences.java:19)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more

Preferences.java line 19 is: a
ddPreferencesFromResource(R.xml.userpreferences);


userpreferences.xml is:

<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen

  xmlns:android="http://schemas.android.com/apk/res/android";>

  <CheckBoxPreference

    android:key="PREF_AUTO_UPDATE"

    android:title="Auto refresh"

    android:summary="Select to turn on automatic updating"

    android:defaultValue="false"

  />

  <ListPreference

   android:key="PREF_UPDATE_FREQ"

   android:title="Refresh frequency"

   android:summary="Frequency at which to refresh earthquake list"

   android:entries="@array/update_freq_options"

   android:entryValues="@array/update_freq_values"

   android:dialogTitle="Refresh frequency"

   android:defaultValue="60"

  />

  <ListPreference

    android:key="PREF_MIN_MAG"

    android:title="Minimum magnitude"

    android:summary="Select the minimum magnitude earthquake to report"

    android:entries="@array/magnitude_options"

    android:entryValues="@array/magnitude"

    android:dialogTitle="Magnitude"

    android:defaultValue="3"

  />

</PreferenceScreen>


The preferences activity is declared in the manifest and launched through:


case (MENU_PREFERENCES): {

Intent i = new Intent(this, Preferences.class);

startActivityForResult(i, SHOW_PREFERENCES);

return true;

}


Does anyone have any idea as to what could be causing this problem? Please
help as this error is live on the market and I could lose users because of
it.

Thanks

-- 
Raghav Sood
http://www.raghavsood.com/
http://www.androidappcheck.com/
http://www.telstop.tel/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to