我已经调试了这个问题一段时间了,我无法找到我将布尔值设置为字符串或其他什么的地方。如果需要,我可以展示更多,但如果你在我的堆栈跟踪中看到任何内容,请告诉我。
我的stacktrace:
08-13 21:25:14.685: D/SensorManager(10583): unregisterListener:: Listener= android.view.OrientationEventListener$SensorEventListenerImpl@41fc5a08
08-13 21:25:14.685: D/Sensors(10583): Remain listener = Sending .. normal delay 200ms
08-13 21:25:14.685: I/Sensors(10583): sendDelay --- 200000000
08-13 21:25:14.685: D/SensorManager(10583): JNI - sendDelay
08-13 21:25:14.685: I/SensorManager(10583): Set normal delay = true
08-13 21:25:14.685: D/SensorManager(10583): registerListener :: handle = 0 name= LSM330DLC Acceleration Sensor delay= 200000 Listener= android.view.OrientationEventListener$SensorEventListenerImpl@41fd3b80
08-13 21:25:14.700: W/IInputConnectionWrapper(10583): getSelectedText on inactive InputConnection
08-13 21:25:14.700: W/IInputConnectionWrapper(10583): getTextBeforeCursor on inactive InputConnection
08-13 21:25:14.700: W/IInputConnectionWrapper(10583): getTextAfterCursor on inactive InputConnection
08-13 21:25:14.720: W/IInputConnectionWrapper(10583): getSelectedText on inactive InputConnection
08-13 21:25:14.720: W/IInputConnectionWrapper(10583): setComposingText on inactive InputConnection
08-13 21:25:14.745: W/IInputConnectionWrapper(10583): getExtractedText on inactive InputConnection
08-13 21:25:18.870: D/SensorManager(10583): unregisterListener:: Listener= android.view.OrientationEventListener$SensorEventListenerImpl@41fd3b80
08-13 21:25:18.870: D/Sensors(10583): Remain listener = Sending .. normal delay 200ms
08-13 21:25:18.870: I/Sensors(10583): sendDelay --- 200000000
08-13 21:25:18.870: D/SensorManager(10583): JNI - sendDelay
08-13 21:25:18.870: I/SensorManager(10583): Set normal delay = true
08-13 21:25:18.870: D/SensorManager(10583): registerListener :: handle = 0 name= LSM330DLC Acceleration Sensor delay= 200000 Listener= android.view.OrientationEventListener$SensorEventListenerImpl@41fcc0c8
08-13 21:25:18.890: W/IInputConnectionWrapper(10583): getSelectedText on inactive InputConnection
08-13 21:25:18.890: W/IInputConnectionWrapper(10583): getTextBeforeCursor on inactive InputConnection
08-13 21:25:18.890: W/IInputConnectionWrapper(10583): getTextAfterCursor on inactive InputConnection
08-13 21:25:18.915: W/IInputConnectionWrapper(10583): getSelectedText on inactive InputConnection
08-13 21:25:18.915: W/IInputConnectionWrapper(10583): setComposingText on inactive InputConnection
08-13 21:25:18.940: W/IInputConnectionWrapper(10583): getExtractedText on inactive InputConnection
08-13 21:25:23.970: D/GestureDetector(10583): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 2 mFalseSizeCnt:0
08-13 21:25:23.975: I/System.out(10583): To
08-13 21:25:24.265: D/dalvikvm(10583): GC_CONCURRENT freed 337K, 7% free 12783K/13639K, paused 2ms+13ms, total 26ms
08-13 21:25:25.800: D/dalvikvm(10583): GC_CONCURRENT freed 330K, 7% free 12931K/13831K, paused 2ms+12ms, total 23ms
08-13 21:25:28.900: D/GestureDetector(10583): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 2 mFalseSizeCnt:0
08-13 21:25:29.505: D/GestureDetector(10583): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 2 mFalseSizeCnt:0
08-13 21:25:29.665: D/SensorManager(10583): unregisterListener:: Listener= android.view.OrientationEventListener$SensorEventListenerImpl@41fcc0c8
08-13 21:25:29.665: D/Sensors(10583): Remain listener = Sending .. normal delay 200ms
08-13 21:25:29.665: I/Sensors(10583): sendDelay --- 200000000
08-13 21:25:29.665: D/SensorManager(10583): JNI - sendDelay
08-13 21:25:29.665: I/SensorManager(10583): Set normal delay = true
08-13 21:25:29.760: W/IInputConnectionWrapper(10583): getSelectedText on inactive InputConnection
08-13 21:25:29.760: W/IInputConnectionWrapper(10583): setComposingText on inactive InputConnection
08-13 21:25:29.760: W/IInputConnectionWrapper(10583): getExtractedText on inactive InputConnection
08-13 21:25:31.010: D/AbsListView(10583): Get MotionRecognitionManager
08-13 21:25:31.690: D/GestureDetector(10583): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 3 mFalseSizeCnt:0
08-13 21:25:31.890: D/AbsListView(10583): Get MotionRecognitionManager
08-13 21:25:31.895: D/AbsListView(10583): Get MotionRecognitionManager
08-13 21:25:31.905: D/AndroidRuntime(10583): Shutting down VM
08-13 21:25:31.905: W/dalvikvm(10583): threadid=1: thread exiting with uncaught exception (group=0x413782a0)
08-13 21:25:31.910: E/AndroidRuntime(10583): FATAL EXCEPTION: main
08-13 21:25:31.910: E/AndroidRuntime(10583): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jordan.dictation/com.jordan.dictation.Settings_ActivityBH}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.os.Handler.dispatchMessage(Handler.java:99)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.os.Looper.loop(Looper.java:137)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.ActivityThread.main(ActivityThread.java:4898)
08-13 21:25:31.910: E/AndroidRuntime(10583): at java.lang.reflect.Method.invokeNative(Native Method)
08-13 21:25:31.910: E/AndroidRuntime(10583): at java.lang.reflect.Method.invoke(Method.java:511)
08-13 21:25:31.910: E/AndroidRuntime(10583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-13 21:25:31.910: E/AndroidRuntime(10583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-13 21:25:31.910: E/AndroidRuntime(10583): at dalvik.system.NativeStart.main(Native Method)
08-13 21:25:31.910: E/AndroidRuntime(10583): Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.SharedPreferencesImpl.getBoolean(SharedPreferencesImpl.java:242)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.Preference.getPersistedBoolean(Preference.java:1630)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.TwoStatePreference.onSetInitialValue(TwoStatePreference.java:184)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.Preference.dispatchSetInitialValue(Preference.java:1315)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.Preference.onAttachedToHierarchy(Preference.java:1127)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.PreferenceGroup.addPreference(PreferenceGroup.java:156)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:97)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:38)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.GenericInflater.rInflate(GenericInflater.java:488)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.GenericInflater.inflate(GenericInflater.java:326)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:269)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:305)
08-13 21:25:31.910: E/AndroidRuntime(10583): at com.jordan.dictation.Settings_ActivityAH.onCreate(Settings_ActivityAH.java:20)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:796)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.BackStackRecord.run(BackStackRecord.java:635)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.Activity.performStart(Activity.java:5200)
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
08-13 21:25:31.910: E/AndroidRuntime(10583): ... 11 more
08-13 21:25:31.925: D/dalvikvm(10583): GC_CONCURRENT freed 301K, 6% free 13073K/13895K, paused 2ms+4ms, total 15ms
08-13 21:25:31.925: D/AbsListView(10583): [unregisterDoubleTapMotionListener]
08-13 21:25:31.925: I/MotionRecognitionManager(10583): .unregisterListener : / listener count = 0->0, listener=android.widget.AbsListView$4@4209b458
08-13 21:25:50.045: I/Process(10583): Sending signal. PID: 10583 SIG: 9
答案 0 :(得分:5)
检查线路:
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
08-13 21:25:31.910: E/AndroidRuntime(10583): at android.app.SharedPreferencesImpl.getBoolean(SharedPreferencesImpl.java:242)
看起来,您正在将值保存为共享首选项中的String并将其作为布尔值读回,这会导致此异常。
检查哪种值-String / Boolean适合您,并保存并读取相似类型的值以解决此问题。
就像您在共享首选项中保存字符串值一样,请将其作为字符串读回。 或者,如果您需要将值读取为布尔值,请将其另存为布尔值。
答案 1 :(得分:1)
如果您已保存“共享首选项”'有钥匙存储或等,使用'字符串'值,然后您使用相同的键来检查' CheckBoxPreference'要求改变后。
在这种情况下,您必须从youphone中删除sharedPreferences for youur app。因为先前存储的值是String,而现在key用于存储Boolean。
答案 2 :(得分:0)
您必须在共享首选项中传递一个值并将其作为布尔类型传递,但将该值作为字符串传递。我的意思是你必须像这样传递真或假 - “真实”,你需要像这样传递它 - 真实。