A DIALOG is usually a small window that appears in front of the current Activity. The underlying Activity loses focus and the dialog accepts all user interaction. Dialogs are normally used for notifications that should interrupt the user and to perform short tasks that directly relate to the application in progress (such as a progress bar or a login prompt).
The Dialog class is the base class for creating dialogs. However, you typically should not instantiate a Dialog directly. Instead, you should use one of the following subclasses:
A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.
A dialog that can manage zero, one, two, or three buttons, and/or a list of selectable items that can include checkboxes or radio buttons. The AlertDialog is capable of constructing most dialog user interfaces and is the suggested dialog type.
A dialog that displays a progress wheel or a progress bar. Because it’s an extension of the AlertDialog, it also supports buttons.
A dialog showing a progress indicator and an optional text message or view. Only a text message or a view can be used at the same time.
The dialog can be made cancelable on back key press.
The progress range is 0..10000.
A dialog that allows the user to select a date. See the Hello DatePicker tutorial.
Date Picker Dialog and Time Picker Dialog in Android use to select a date and time, as it will be popup when you needed. While Time Picker and Date Picker widget occupy more space on screen. Dialogs are the best way to solve this issue.
A dialog that allows the user to select a time. See the Hello TimePicker tutorial.
If you would like to customize your own dialog, you can extend the base Dialog object or any of the subclasses listed above and define a new layout.
Get Updates on Tech posts, Interview & Certification questions and training schedules