I need to show a login screen each time user is openning or switching between the apps.
I have implemented a solution to open a LoginActivity in needed cases. When user open a minimised app, LoginActivity was opened on the top of the backstack. As I wanted to make app secure and restrict back navigation, I used Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK flags, so the backstack was cleared.
But now I need to keep a backstack. What would be a better solution? Save the state of the openned activities (and how to do it better)? Or to restrict back button navigation somehow and just finish LoginActivity if the login was successfull? Is it safe to show LoginActivity ot the top of the backstack?