I created this code to close the app for it instead of closing the restart. I have of the Mainactivity being that the first one has a splash screen. What I have to change.
public void existapp (View View) { existsapp (); }
private void existeapp() {
AlertDialog.Builder builder = new AlertDialog.Builder(Main2Activity.this);
builder.setMessage("Do you want to exit?");
builder.setCancelable(true);
builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
System.exit(0);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}