Closing ProgressDialog onClick

I run AsyncTask to download a file that takes some time. To tell the user, I show the ProgressDialog , however, if I touch the screen, the ProgressDialog closes immediately. What could be the reason for this?

  public LoadTask(Activity activity, FaceRecognizer recognizer,SecretKey key) { this.key = key; this.recognizer = recognizer; dialog = new ProgressDialog(activity); } @Override protected void onPreExecute() { dialog.setMessage("Loading the recognizer..."); dialog.show(); } @Override protected Boolean doInBackground(Void... params) { recognizer.load(key); return null; } @Override protected void onPostExecute(Boolean result) { if (dialog.isShowing()) { dialog.dismiss(); } 
+4
source share
3 answers

use this ...

 public LoadTask(Activity activity, FaceRecognizer recognizer,SecretKey key) { this.key = key; this.recognizer = recognizer; dialog = new ProgressDialog(activity); /////////////////////////////////////////// dialog.setCancelable(false); //or//////// dialog.setCanceledOnTouchOutside(false); } 
+6
source

Try:

 dialog.setIndeterminate(); dialog.setCancelable(false); 
0
source

Source: https://habr.com/ru/post/1447318/


All Articles