PedroC88 PedroC88 - 1 year ago 59
Android Question

Exception on ListPreferences

This is my first Android app and I've encountered an exception when trying to use the ListPreference. The application loads along with the preferences... but when i touch the ListPreference entry the applications "stops unexpectedly".

public class Settings extends PreferenceActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {


<?xml version="1.0" encoding="utf-8"?>
android:summary="SMS response based on settings"
android:summary="Contacs that will be sent SMSs"


<?xml version="1.0" encoding="utf-8"?>
<string-array name="list_entries">

<integer-array name="list_values">

This is the logcat output:

D/AndroidRuntime( 3187): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 3187): CheckJNI is OFF
D/AndroidRuntime( 3187): --- registering native functions ---
I/jdwp ( 3187): received file descriptor 16 from ADB
/ddm-heap( 3187): Got feature list request
I/ActivityManager( 86): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=tml.UI.main/.MainActivity }
D/AndroidRuntime( 3187): Shutting down VM
D/dalvikvm( 3187): DestroyJavaVM waiting for non-daemon threads to exit
I/ActivityManager( 86): Start proc tml.UI.main for activity tml.UI.main/.MainActivity: pid=3194 uid=10039 gids={1015}
D/dalvikvm( 3187): DestroyJavaVM shutting VM down
D/dalvikvm( 3187): HeapWorker thread shutting down
D/dalvikvm( 3187): HeapWorker thread has shut down
D/jdwp ( 3187): JDWP shutting down net...
D/jdwp ( 3187): +++ peer disconnected
I/dalvikvm( 3187): Debugger has detached; object registry had 1 entries
D/dalvikvm( 3187): VM cleaning up
D/dalvikvm( 3187): LinearAlloc 0x0 used 676380 of 4194304 (16%)
I/jdwp ( 3194): received file descriptor 10 from ADB
D/ddm-heap( 3194): Got feature list request
W/Resources( 3194): Converting to string: TypedValue{t=0x10/d=0x0 a=-1}
I/ActivityManager( 86): Displayed activity tml.UI.main/.MainActivity: 977 ms (total 977 ms)
D/AndroidRuntime( 3194): Shutting down VM
W/dalvikvm( 3194): threadid=3: thread exiting with uncaught exception (group=0x4001da28)
E/AndroidRuntime( 3194): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3194): java.lang.NullPointerException
E/AndroidRuntime( 3194): at android.preference.ListPreference.findIndexOfValue(
E/AndroidRuntime( 3194): at android.preference.ListPreference.getValueIndex(
E/AndroidRuntime( 3194): at android.preference.ListPreference.onPrepareDialogBuilder(
E/AndroidRuntime( 3194): at android.preference.DialogPreference.showDialog(
E/AndroidRuntime( 3194): at android.preference.DialogPreference.onClick(
E/AndroidRuntime( 3194): at android.preference.Preference.performClick(
E/AndroidRuntime( 3194): at android.preference.PreferenceScreen.onItemClick(
E/AndroidRuntime( 3194): at android.widget.AdapterView.performItemClick(
E/AndroidRuntime( 3194): at android.widget.ListView.performItemClick(
E/AndroidRuntime( 3194): at android.widget.AbsListView$
E/AndroidRuntime( 3194): at android.os.Handler.handleCallback(
E/AndroidRuntime( 3194): at android.os.Handler.dispatchMessage(
E/AndroidRuntime( 3194): at android.os.Looper.loop(
E/AndroidRuntime( 3194): at
E/AndroidRuntime( 3194): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3194): at java.lang.reflect.Method.invoke(
E/AndroidRuntime( 3194): at$
E/AndroidRuntime( 3194): at
E/AndroidRuntime( 3194): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 86): Sending signal. PID: 3194 SIG: 3
I/dalvikvm( 3194): threadid=7: reacting to signal 3
I/dalvikvm( 3194): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 3194): Sending signal. PID: 3194 SIG: 9
I/ActivityManager( 86): Process tml.UI.main (pid 3194) has died.
I/WindowManager( 86): WIN DEATH: Window{4341fd00 tml.UI.main/tml.UI.main.MainActivity paused=false}
W/UsageStats( 86): Unexpected resume of while already resumed in tml.UI.main
W/InputManagerService( 86): Got RemoteException sending setActive(false) notification to pid 3194 uid 10039

Answer Source

I fixed it... I kept on trying and, at the end, it turns out that I cannot use an integer-array as the entryValues Source. I just changed that integer-array to a string-array and got it working.

If there's a way to use integer-array as the source for entryValues please comment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download