我使用ProgressDialog
Thread 或AsyncTask
.
和线程AsyncTask
工作。但在完成工作ProgressDialog
Dismiss 并得到 force close 。
在onCreate()
我称之为
new myAsyncTask().execute();
异步任务
private class myAsyncTask extends AsyncTask<Void, Void, String>
{
ProgressDialog dialog;
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(MainActivity.this, "", "Please Wait !",true,false);
}
@Override
protected String doInBackground(Void... params) {
startProgram();
return "";
}
@Override
protected void onPostExecute(String result) {
if (dialog.isShowing())
dialog.dismiss();
}
}