In some of application we need to implement logout functionality this is one of very easy way to clear all history in your application of activity.

Intent i= new Intent(MainActivity.this, Login.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);
finish();

🙂