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.
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.
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).
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.
DelayedProgressDialog progressDialog = new DelayedProgressDialog(); progressDialog.show(getSupportFragmentManager(), "tag");