I wanted to know which component can be a substitute for it (.).
The suggested replacement is ProgressBar . Both ProgressDialog and ProgressBar , have existed since the initial version of Android.
I was reading about Progress Bar but does not it work that way or work?
Yes, if it refers to the possibility of starting and stopping it. The difference is that one is a dialog while the other is displayed "inside" the layout .
ProgressDialog was considered obsolete on Android O (Api Level 26) which, on this date, is the latest version.
The fact that it is considered obsolete does not imply that it can not be used.
The main reason, in my opinion, for ProgressDialog to be considered obsolete, has to do with user experience - the presentation of a dialog limits user interaction with the application, while task is running.
See the question Best practices when displaying the loading screen on Android , where Luiz Vieira in his answer , addresses the issue from a "usability" perspective.
In my answer , you can find an example of using ProgressBar.