Project: titanium
Issue TIMOB-18132: Android: App Crashes with CalledFromWrongThreadException opening DatePicker after typing in a tf
h4. Problem Description App crashes with CalledFromWrongThreadException when switching from textedit to datepicker h4. Steps to reproduce 1. Create a new mobile project classic titanium 2. Add this code to app.js: {code:javascript} var win = Ti.UI.createWindow({title:'test',layout:'vertical'}); win.open(); var label = Ti.UI.createTextField({value:'Hello world',top:50,bottom:50,height:Ti.UI.SIZE,width:Ti.UI.FILL}); win.add(label); var picker = Ti.UI.createPicker({value : new Date(),type: Ti.UI.PICKER_TYPE_DATE}); var pickDateButton = Ti.UI.createButton({title:'pick a date'}); win.add(pickDateButton); pickDateButton.addEventListener('click',function(){ picker.showDatePickerDialog({ value:new Date(), callback:function(e){ Ti.API.info('picked date: '+JSON.stringify(e)); } }); }); {code} 3. Run the app in a Samsung S3 device (Please: make sure to use the S3 device, it's not easily reproducible in other devices). 4. Click in the Textfield 5. Start type something 6. Click on the button to open the date picker . 7. The app should crash. h4. Extra info I included the adb log of the errror {color:red} /dalvikvm(27883): threadid=10: thread exiting with uncaught exception (group=0x4174ee48) E/AndroidRuntime(27883): FATAL EXCEPTION: KrollRuntimeThread E/AndroidRuntime(27883): Process: com.debugging.test, PID: 27883 E/AndroidRuntime(27883): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. E/AndroidRuntime(27883): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6347) E/AndroidRuntime(27883): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:871) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.widget.ScrollView.requestLayout(ScrollView.java:1481) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472) E/AndroidRuntime(27883): at android.widget.TextView.checkForResize(TextView.java:6760) E/AndroidRuntime(27883): at android.widget.TextView.updateAfterEdit(TextView.java:7681) E/AndroidRuntime(27883): at android.widget.Editor.finishBatchEdit(Editor.java:1322) E/AndroidRuntime(27883): at android.widget.Editor.endBatchEdit(Editor.java:1305) E/AndroidRuntime(27883): at android.widget.TextView.endBatchEdit(TextView.java:6065) E/AndroidRuntime(27883): at com.android.internal.widget.EditableInputConnection.endBatchEdit(EditableInputConnection.java:77) E/AndroidRuntime(27883): at android.view.inputmethod.BaseInputConnection.finishComposingText(BaseInputConnection.java:288) E/AndroidRuntime(27883): at android.view.inputmethod.InputMethodManager.checkFocusNoStartInput(InputMethodManager.java:1358) E/AndroidRuntime(27883): at android.view.inputmethod.InputMethodManager.onWindowFocus(InputMethodManager.java:1402) E/AndroidRuntime(27883): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3198) E/AndroidRuntime(27883): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(27883): at android.os.Looper.loop(Looper.java:136) E/AndroidRuntime(27883): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) W/ActivityManager( 886): Force finishing activity com.debugging.test/org.appcelerator.titanium.TiActivity V/ActivityManager( 886): Moving to PAUSING: ActivityRecord{422ff478 u0 com.debugging.test/org.appcelerator.titanium.TiActivity t1034 f} {color}
Story points: 8