贴其中一段代码:
public class SwitchColor extends AsyncTask<Bitmap, String, Bitmap>{
@Override
protected void onPreExecute() {
switchDialog=ProgressDialog.show(PreviewActivity.this, "", getResources().getString(R.string.processing_loading));
super.onPreExecute();
}
@Override
protected Bitmap doInBackground(Bitmap... params) {
Bitmap newBitmap=switchColor(params[0]);
return newBitmap;
}
@Override
protected void onPostExecute(Bitmap result) {
showGreyBitmap(result);
switchDialog.dismiss();
}
}
problem:在doInBackground完成之后,彩色图片转换成黑白图片并且展示出来后,switchDialog才出现
其实问题出现在调用这个线程的代码:
new SwitchColo().execute(tempBitmp).get();
AsyncTask类的get方法底层代码中有await,会给主线程让位!!所以造成线程阻塞,导致progressDialog的UI出不来
在此多谢Simon哥无私帮助~!!