How can I make a ProgressDialog be cancelable by the back button but not by a screen tap?
Asked Answered
L

2

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.

Laban answered 11/11, 2011 at 21:32 Comment(0)
J
65

Use setCanceledOnTouchOutside(false).

Jemadar answered 11/11, 2011 at 21:47 Comment(2)
I'll do this as soon as I get in tomorrow and post my progress. Thanks!Laban
Thank you ! Saved me a lot of time ! The setCancellable(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 !Urethroscope
S
3

Try this it will help you:

ProgressDialog pd = ProgressDialog.show(main.this, "", "Loading. Please wait...", true);
pd.setCancelable(true);`
Stereochrome answered 12/6, 2012 at 12:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.