29

I would like to make a ProgressDialog cancelable by the back button but not by a screen tap. Currently I use setCancelable(true).

However, in some newer devices a tap on the screen also cancels the ProgressDialog. I'd like to disable the screen tap action while the ProgressDialog is shown.

makes
  • 6,438
  • 3
  • 40
  • 58
benkdev
  • 673
  • 2
  • 16
  • 32

2 Answers2

65

Use setCanceledOnTouchOutside(false).

Kimi
  • 6,239
  • 5
  • 32
  • 49
  • I'll do this as soon as I get in tomorrow and post my progress. Thanks! – benkdev Nov 12 '11 at 03:42
  • Thank you ! Saved me a lot of time ! The [setCancellable(boolean)](http://developer.android.com/reference/android/app/AlertDialog.Builder.html#setCancelable(boolean)) method of the **AlertDialog Builder** is misleading; it only handles the dialog being cancelled from the back button. The **cancelable by touch** property should also be available from the builder ! – Leeeeeeelo May 29 '13 at 08:13
3

Try this it will help you:

ProgressDialog pd = ProgressDialog.show(main.this, "", "Loading. Please wait...", true);
pd.setCancelable(true);`
ol_v_er
  • 27,094
  • 6
  • 48
  • 61
Jay Thakkar
  • 743
  • 1
  • 5
  • 24