I put Alert dialog builder inside my if else statement. Now, I want to do is to automatic dismiss the dialog in "if" statement and show the dialog in "else" statement. So, here is my codes.
public void DisplayConn(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Error");
builder.setMessage("No Network Connection").setCancelable(false);
AlertDialog alert = builder.create();
if(isNetworkStatusAvailable(getApplicationContext())){
alert.dismiss();
} else {
alert.show();
}
}
I don't want to use onClick button to dismiss the dialog, I just want to automatic dismiss the dialog in "if" statement. It is possible? Thanks in advance.