UI线程阻塞导致主界面无法刷新
错误如下:
06-15 04:33:34.789: W/dalvikvm(2924): threadid=14: thread exiting with uncaught exception (group=0x40a791f8)
06-1504:33:34.789:E/AndroidRuntime(2924):FATALEXCEPTION:ComposeHandler
06-1504:33:34.789:E/AndroidRuntime(2924):android.view.ViewRootImpl$CalledFromWrongThreadException:Onlytheoriginalthreadthatcreatedaviewhierarchycantouchitsviews.
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.ViewRootImpl.checkThread(ViewRootImpl.java:4109)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.ViewRootImpl.requestLayout(ViewRootImpl.java:709)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.widget.RelativeLayout.requestLayout(RelativeLayout.java:268)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.requestLayout(View.java:12710)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.setFlags(View.java:6728)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.view.View.setVisibility(View.java:4625)
06-1504:33:34.789:E/AndroidRuntime(2924):atcom.android.mms.ui.ComposeMessageActivity.updateTypingIcon(ComposeMessageActivity.java:8182)
06-1504:33:34.789:E/AndroidRuntime(2924):atcom.android.mms.ui.ComposeMessageActivity.access$9700(ComposeMessageActivity.java:257)
06-1504:33:34.789:E/AndroidRuntime(2924):atcom.android.mms.ui.ComposeMessageActivity$ComposeEventHdlr.handleMessage(ComposeMessageActivity.java:8619)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.os.Handler.dispatchMessage(Handler.java:99)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.os.Looper.loop(Looper.java:137)
06-1504:33:34.789:E/AndroidRuntime(2924):atandroid.os.HandlerThread.run(HandlerThread.java:60)
06-15 04:33:34.820: W/ActivityManager(224): Force finishing activity com.android.mms/.ui.ComposeMessageActivity修改方法:
将更新UI代码加入到activity的UI线程队列中
/*<Hap5.2 Message+ kf55773 2012-06-15 begin */
privatevoidupdateTypingIcon(finalbooleanaEnableTyping){
ComposeMessageActivity.this.runOnUiThread(newRunnable(){
publicvoidrun(){
if(null==mTypingIcon){
/*modifiedbyMessage+kf3692220120207begin*/
mTypingIcon=(GifView)findViewById(R.id.typing);
/*modifiedbyMessage+kf3692220120207end*/
}
if(aEnableTyping){
mTypingIcon.setVisibility(View.VISIBLE);
}else{
mTypingIcon.setVisibility(View.GONE);
}
}
});
}
/*<Hap5.2 Message+ kf55773 2012-06-15 end */