When your application is resumed through recent apps, it is common to use Android's onResume()
method to get things done.
If you, for instance, want the 8th activity to be started, you could do so there through Intents to call the class and check your passcode there. If it's correct, then you can return to activity 7 through Android's finish()
method which returns to the last activity on the backstack.
You could take a look at implementing this through the Dialogs API as well, which has a custom implementation for a log in modal.