I'm working on an android project which displays a progress dialog when the user downloads a file.
But when the user touches the screen, the progress dialog is dismissed without waiting the 100%. I already tried to use this:
public boolean onTouchEvent(MotionEvent e) { return true; }
But it's not working.
How can I avoid this?
UPDATE 1:
It seems that setCancelable(false) works fine. Thanks you very much for your answers but when the downloading long-lasting and the user decides to abandon it'll be impossible because I already deactivated the back keyCode:
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { return true; } return super.onKeyDown(keyCode, event); }
How can I figure this out?
ProgressBar is best alternative for ProgressDialog.
You want to stop the progressDialog or change its UI not to be circular? You can set your progressbar's visibility to invisible or gone through progressbar. setVisibility(View. INVISIBLE); or progressBar.
Use dialog.setCancelable(false);
Example :
ProgressDialog dialog = new ProgressDialog(WiFiFinderActivity.this); dialog.setMessage("please wait..."); dialog.show(); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With