I have 2 activities, but since the second activity is allowing me to return with the back button, which should not happen, how to avoid this situation
Activity 1
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
overridePendingTransition(0, 0);
is it necessary to put finish() ?. And I have a second question, what is the difference between setFlags and addFlags, where to use each?