20

I was reading about Dialogs in Android site and I came across a section that saying "Avoid ProgressDialog".

Here is the link: http://developer.android.com/guide/topics/ui/dialogs.html

does that means they recommend not to use it? I really need a popup with showing progress while my app is doing background work.

Does that means I have to build my own Progress Dialog using ProgressBar class? How would one build it by the way? Any help is appreciated.

Hong Wei Wang
  • 1,388
  • 3
  • 19
  • 29

2 Answers2

40

Edit: With Android O, ProgressDialog is now officially deprecated. An alternative is approach is suggested

This class was deprecated in API level O. Use a progress indicator such as ProgressBar inline inside of an activity rather than using this modal dialog.


Original answer:

This is all from a design & user interaction perspective, not a code perspective.

The UI guidelines are telling you to avoid using a ProgressDialog not because the class is deprecated (it is not at the time of writing this answer), but rather because it forces the user to avoid interacting with the application and merely stare at the screen.

Take the Google Play app as an example. While it downloads an application/update, you can still swipe, navigate, etc. You can still be involved with the app while it is doing something.

If you absolutely need the user to cease interaction until the progress bar finishes, by all means do so. The docs are merely saying you may be able to find better ways of doing it (hence the link to Progress & Activity).

A--C
  • 36,351
  • 10
  • 106
  • 92
  • 1
    I see what you mean. Thanks for your answer! – Hong Wei Wang Jan 16 '14 at 03:44
  • @HongWeiWang No problem. Also, I don't see the point of building your own `Dialog` that mimics a `ProgressDialog`. As I said, there is nothing wrong with using it. – A--C Jan 16 '14 at 03:52
  • Well, if I custom it, I am able to add more stuff to the popup it self. – Hong Wei Wang Jan 16 '14 at 03:54
  • @HongWeiWang That is true. Keep in mind though, that whether or not you use `ProgressBarDialog` or a "clone", the doc's warning to avoid such dialogs (which is the topic of the question, and which and I answered) still applies. – A--C Jan 16 '14 at 03:56
  • 1
    `ProgressDialog` is deprecated in O. – 0xcaff Mar 28 '17 at 06:15
  • @caffinatedmonkey Thanks, updated the answer to reflect that – A--C Mar 29 '17 at 00:22
1

With ProgressDialog being deprecated in Android O. You should create a ProgressBar and show it by setting it's visibility. I use DelayedProgressDialog from https://github.com/Q115/DelayedProgressDialog It does the same as ProgressDialog with the added benefit of a delay if necessary.

Usage:

DelayedProgressDialog progressDialog = new DelayedProgressDialog();
progressDialog.show(getSupportFragmentManager(), "tag");
NinjaCowgirl
  • 2,301
  • 2
  • 13
  • 14