EditText weird crash on LG Optimus w/Swype (works on emulator and Droids)

筅森魡賤 提交于 2019-12-12 09:41:01

问题


I have an app which works in the emulator and on Droid phones. While testing on an LG Optimus (which BTW has Swype installed) it crashes with the following stack trace (NOTE: it is in the constructor of EditText).

What is weird is that supposed offending line in TextView (981) is the method signature for getDefualtView() and there are no references to GestureDetector in EditText or TextView in 2.2 source code.

I'm presuming (or hazarding a guess that it is most likely due to Swype) and am not sure of:

  1. if it is swype, then how do i write my code so that it is swype friendly?
  2. if it is not swype, then what could it be? Whats baffling is that it is in the constructor using default styles, and null for attributes.

any help is appreciated.

Kindest regards, S-

-- stacktrace snip --

05-26 12:28:23.440: ERROR/AndroidRuntime(11912): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.os.Handler.<init>(Handler.java:121)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:250)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector.<init>(GestureDetector.java:370)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector.<init>(GestureDetector.java:347)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector.<init>(GestureDetector.java:331)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.TextView.<init>(TextView.java:981)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.EditText.<init>(EditText.java:55)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.EditText.<init>(EditText.java:51)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.EditText.<init>(EditText.java:47)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.EditTextImpl.<init>(EditTextImpl.java:28)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.TextFieldImpl.makeTextView(TextFieldImpl.java:23)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.ToolkitImpl.createTextField(ToolkitImpl.java:429)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.ToolkitImpl.createWidgets(ToolkitImpl.java:492)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.ToolkitImpl.initializeContainer(ToolkitImpl.java:555)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.common.gui.WidgetContainer.initializeImpl(WidgetContainer.java:88)

-- end stack trace --

Blockquote


回答1:


I looked into sources and it seems that invoking Looper.prepare() in the UI thread will fix this exeption. But it's very strange. Are you using multiple threads?



来源:https://stackoverflow.com/questions/6144823/edittext-weird-crash-on-lg-optimus-w-swype-works-on-emulator-and-droids

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!