In Android, if you want to clear your current Activity stack and launch a new Activity (for example, logging out of the app and launching a log in
Activity
If API >= 21, you can use the command of:
finishAndRemoveTask ();
Finishes all activities in this task and removes it from the recent tasks list.
https://developer.android.com/reference/android/app/ActivityManager.AppTask.html