Code tạo progress dialog hiển thị tiến trình trong android java

Code: Java | Auth: 03cd82
//Dialog này hiển thị trong 30s sẽ tự tắt   

        ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);

        progressDialog.setTitle("Tiêu đề dialog");
        progressDialog.setMessage("Nội dung dialog");
        progressDialog.setCancelable(false); // không cho phép tắt dialog, nếu bỏ dòng này hoặc để true sẽ tự tắt
		// nếu bạn muốn hiển thị nút bấm thì thêm code setButton, nếu không thì bỏ qua lệnh setButton
        progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                progressDialog.dismiss();
            }
        });
 

        progressDialog.show();

		// tạo tiến trình đếm ngược để tự tắt dialog
        new CountDownTimer(30000, 1000) {

            public void onTick(long millisUntilFinished) {
                progressDialog.setMessage("seconds remaining: " + millisUntilFinished / 1000);
            }

            public void onFinish() {
                progressDialog.dismiss();
            }
        }.start();