此代码将使用推荐的AsyncTask来完成您想做的事情!
private class MakePDF extends AsyncTask<Void, Void, Void> { private ProgressDialog processingDialog; Context cnt = null;MakePDF(Context cnt) { this.cnt = cnt; } @Override protected void onPreExecute() { super.onPreExecute(); processingDialog = ProgressDialog.show( this.cnt, "Creating PDF", "Please wait ...", true, false); } @Override protected Void doInBackground(Void... arg0) { createPDF(); return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); processingDialog.dismiss(); viewPDF(); } }现在使用以下命令在AsyncTask上方调用
new MakePDF(ActivityName.this).execute(); //here in constructor pass context of an calling activity.
从你的活动课



