咖啡伴侣

呆在上海
posts - 163, comments - 156, trackbacks - 0, articles - 2
遇到的情况
AsyncTask
protected GAViewer doInBackground(Activity... params) {
    ......
    GAViewer viewer = new GAViewer(result, drawActivity.getApplicationContext());
    return viewer;
}

产生
Can't create handler inside thread that has not called Looper.prepare()
异常

原因估计
1.viewer 是个 SurfaceView ,而doInBackground是不允许操作UI的
2.drawActivity.getApplicationContext() 已经操作了UI ?maybe

Feedback

# re: Can't create handler inside thread that has not called Looper.prepare() 异常问题[未登录]  回复  更多评论   

2011-11-28 20:06 by mark
android webkit plugin

线程里回调javascript函数时,插件直接崩溃,并提示:

WARN/System.err(296): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
原因是,另外一线程不能更新UI主线程。插件提供同步函数。用这个pluginthreadasynccall,再调用invokeDefault就可以了。


只有注册用户登录后才能发表评论。


网站导航: