You need to provide an OnClickListener
where you can call finish()
for your activity.
.setNegativeButton(android.R.string.no, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//replace MainActivity with your activity's name
MainActivity.this.finish();
}
})
solved AlertDialog, kill activity onClick “NO” [duplicate]