展示dialog的,结束任务后,自动消失

//创建对话框
private void showLoadProgress(){
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setCanceledOnTouchOutside(false);
    mProgressDialog.setTitle("Scan Application");
    mProgressDialog.setMessage("Loading ...");

    mProgressDialog.show();

}


private void  queryEmailApplication(final Intent intent){

    new  AsyncTask() {

        @Override
        protected void onPreExecute() {

     //展示对话框
            showLoadProgress();
        }

        @Override
        protected Boolean doInBackground(Void... voids) {
            return checkAppList(intent);
        }

        @Override
        protected void onPostExecute(Boolean hasApp) {
            if (hasApp) {
                intent.setClass(WorkFlowSettingActivity.this, EmailConfigActivity.class);
                startActivity(intent);
   //执行异步任务,结束对话框
                mProgressDialog.dismiss();

            } else {
                //do nothing
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

你可能感兴趣的:(移动开发)