Here is the piece of code that creates my alert dialog:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Battery level less than 20%:"+al)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//do things
}
});
AlertDialog alert = builder.create();
alert.show();