If you want to just clear the previous activities from stack and
launch login activity just do this
in manifest
file your login activity should be like this
<activity
android:name=".LoginActivity"
android:screenOrientation="portrait"/>
After changing password launch the login activity
with following tags
Intent intent = new Intent(ChangePassword.this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
By setting flag to Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
all the previous activities will be cleared from stack.
for more info check this
https://developer.android.com/reference/android/content/Intent
From the official documentation - FLAG_ACTIVITY_CLEAR_TOP
If set, and the activity being launched is already running in the
current task, then instead of launching a new instance of that
activity, all of the other activities on top of it will be closed and
this Intent will be delivered to the (now on top) old activity as a
new Intent.
For example, consider a task consisting of the activities: A, B, C, D.
If D calls startActivity() with an Intent that resolves to the
component of activity B, then C and D will be finished and B receive
the given Intent, resulting in the stack now being: A, B.