An AlertDialog is a more complex “Alert-system”, just for now, we will see how to create the simplest ones: A pop-up, with a message and a button. This time, we will have the control of the focus: Clicking on the button we will give the focus back to the application. With this AlertDialogs we can show critical messages to the user, or info about our application. The only limit is your imagination.

click to enlarge
Now Let's have a look at how to create a simple Alert Dialog, like we can see in the image above.
new AlertDialog.Builder(BrightHub.this)
.setTitle("BrightHub Alert!")
.setMessage("Google Android How-to guides in the Bright Hub")
.setNeutralButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
}).show();
To the AlertDialog Builder we can add methods to define the style, format and content of the Dialog.
.setTitle → Sets the title of the pop-up. Just a String
.setMessage → We can add a message. A String
.setNeutralButton → Here we add a simple button. Parameters: The first one is the text that its going to appear in the button, the second one is a Listener. Do you want something happen when you click the button? Here is the place.
Other methods I have no show are available. For example, if we want to add an image to the Dialog we have to use the .setIcon method (passing a Drawable as parameter).