ProgressDialog is deprecated.What is the alternate one to use?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
ProgressDialog was deprecated because it encouraged a blocking, dialog-centric progress pattern that does not fit modern Android UI design. The replacement is not one single class. The better approach is to show progress inside the current screen, or in a lifecycle-aware dialog or notification, depending on what the user is waiting for.
The Usual Replacement: ProgressBar in the Layout
For most screens, the direct replacement is an embedded ProgressBar. Instead of interrupting the whole app with a modal dialog, show a loading indicator near the content it affects.
A simple XML layout might look like this:
And in an activity or fragment:
This pattern is simple, non-blocking, and survives configuration changes more naturally.
Overlay, Inline, or Notification?
The right alternative depends on the task.
Use an inline ProgressBar when loading content already visible on the screen.
Use an overlay spinner when the user must wait briefly before interacting with the current screen.
Use a foreground service notification or system notification when the work should continue even if the user leaves the app, such as a file upload or long-running sync.
For determinate progress, use the horizontal style and update its progress value rather than showing an indeterminate spinner.
If You Still Need a Dialog
Sometimes a dialog presentation is appropriate, but you should use a normal DialogFragment with a custom view rather than ProgressDialog.
This gives you lifecycle-aware dialog behavior without relying on the deprecated API. Even then, use it sparingly. Dialogs should be the exception, not the default loading pattern.
State Management Matters More Than the Widget
A lot of ProgressDialog problems were actually state-management problems. Modern Android code should drive loading state from ViewModel, LiveData, or StateFlow, then let the UI react.
The fragment observes loading and toggles the progress UI. That architecture is more durable than manually showing and dismissing dialogs from callback chains.
Common Pitfalls
A common mistake is replacing ProgressDialog with AlertDialog and keeping the same blocking UX. That only changes the class name, not the design problem.
Another issue is using a spinner for long background work that should be reported through a notification or work manager flow instead.
Developers also sometimes forget to hide the indicator when an error occurs. Loading state should be cleared in both success and failure paths.
Finally, avoid keeping references to dialogs across activity recreation. Lifecycle-aware UI state is more reliable than imperative show and dismiss calls.
Summary
- '
ProgressDialogis deprecated because blocking dialogs are poor default UX.' - Use
ProgressBarinside the current layout for most loading states. - Use determinate progress when the work has measurable completion.
- If a dialog is truly needed, prefer
DialogFragmentwith a custom view. - Drive progress from lifecycle-aware state instead of manual dialog control.
Related reading
- Proper practice for subclassing UIView?
- Proper Realm usage patterns/best practices?
- Proper usage of the Alamofire's URLRequestConvertible
- Proper use cases for Android UserManager.isUserAGoat?
- Proper use of beginBackgroundTaskWithExpirationHandler
- Proper way to exit iPhone application?
- Proper way to renew distribution certificate for iOS
- Property initializers run before 'self' is available
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.