Home > Back-end >  Why did Google deprecate ProgressDialog class?
Why did Google deprecate ProgressDialog class?

Time:05-19

While browsing to find an alternative to PrgressDialog class I found this article and the writer mentioned this:

As we know Progress Dialog is depreciated in API level 26

because It prevents the user to interact with the app. Let me explain to you why this is bad. As we show the Progress Dialog It runs and blocks the UI and user can’t interact with the App. Until our request is successful or fails basically we get the response of the request whatever we started.

Like Example suppose we are fetching some list of data in Navigation drawer home and started showing the Progress Dialog and as you know It will block the UI and User can’t do anything. Ever user can’t open navigation drawer and choose something else etc things. App UI is blocked, no interaction.

Question 1, I want to ask you, Is it good to keep the user moving between the activities or fragments without blocking the UI even if the connection with the server still running (not finished yet)? I think that will cause a lot of problems

Even when I replace ProgressDialog with the alternative, I still want to block the UI, So do you see any difference?

Maybe I did not understand the idea clearly.

Question 2, Could you tell me why Google deprecated ProgressDialog class?

CodePudding user response:

from the docs it's clear that

ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress.

https://developer.android.com/reference/android/app/ProgressDialog.html

CodePudding user response:

What I believe It makes your activity partially visible thus lifecycle method onPause will be called.

As Lifecycle aware component (live data, view model) are being developed and pushed by google/android. So, It makes sense they want to deprecate it and push ProgressBar as a option that is embedded or part of the same UI.

  • Related