ProgressDialog has become deprecated since API Level 26 https://developer.android.com/reference/android/app/ProgressDialog.html
I include a ProgressBar in my layout
<ProgressBar
android:layout_weight="1"
android:id="@+id/progressBar_cyclic"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="40dp"
android:minWidth="40dp" />
and change its visibility to .GONE | .VISIBLE depending on the use case.
progressBar_cyclic.visibility = View.VISIBLE