所以我正在尝试从异步任务启动进度对话框。
在我的主要活动中,我正在调用异步任务,如下所示:
new OCRScanAsyncTask(getApplication().getApplicationContext()).execute();
也试过:
new OCRScanAsyncTask(getBaseContext()).execute();
我的 asyncTask 看起来像这样:
public class OCRScanAsyncTask extends AsyncTask<String, Integer, Boolean> {
/* (non-Javadoc)
* @see android.os.AsyncTask#doInBackground(Params[])
*/
private ProgressDialog progressDialog;
private String TAG ="OCRAsyncTask";
private String IMAGE_PATH = Environment.getExternalStorageDirectory() + "/bcCardReader/tmp/tmpCrd.jpg";
public static final String DATA_PATH = Environment
.getExternalStorageDirectory().toString() +"/bcCardReader/tmp/";
private String lang = "eng";
private Context context;
public OCRScanAsyncTask(Context c){
Log.v(TAG, "*****************CONSTRUCTING");
context = c;
progressDialog = new ProgressDialog(context);
}
@Override
protected void onPreExecute(){
super.onPreExecute();
Log.v(TAG, "pre exe");
progressDialog.setTitle("Please Wait");
progressDialog.setMessage("Performing Character Recognition");
progressDialog.setIndeterminate(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setCancelable(false);
progressDialog.show();
}
............
我的错误如下所示: