我有以下代码:
protected View progressView;
protected LayoutParams progressParams;
class Task extends AsyncTask<String, Void, Result> {
String timeleft;
String error;
@Override
protected Result doInBackground(String... s) {
// ...
}
@Override
public void onPreExecute() {
getWindowManager().addView(progressView, progressParams);
}
@Override
protected void onPostExecute(Result result) {
getWindowManager().removeView(progressView); // throws exception
// ...
}
}
我在手机上遇到此错误(不在模拟器中)。也许是因为我使用了 tyween 的 HTC HD2 Android ROM,它启用了很多东西并且“生活在边缘”。
03-02 22:53:08.303: E/test(5573): Exception: Hardware acceleration can only be used with a single UI thread.
03-02 22:53:08.303: E/test(5573): Original thread: Thread[main,5,main]
03-02 22:53:08.303: E/test(5573): Current thread: Thread[background thread,5,main]
如何解决此错误?