I have activities [A] [B] [C] in my Android Apps. - [A] is LoginActivity - [B] is DashboardActivity - [C] is InventoryListActivity
in each [B] and [C] activity, theres is a logout button with code :
public void doLogout(){
// clear all preferences
// Return to the login activity
Intent intent = new Intent(getBaseContext(), LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
When i try to execute logout button in [C] activity with this flow [A] --> [B] --> [C], it does go to LoginActivty, but when i press back button it goes to [B] activity. What i want is if back button pressed i want to go Android Home Screen.
Please advise, how to destroy all activity when logout function executed.