I'm creating a Wizard-style application, where I need to keep the user data between activities A and B alive. A has a Next soft button and B has a Back soft button.
When using FLAG_ACTIVITY_REORDER_TO_FRONT
I can keep the user data alive when the soft buttons are used, because each activity is reused.
But, when the user presses the Back hard button from B, B dies, due to that hard button uses finish() implicitly.
Then, I tried overriding onBackPressed
in B, adding to it the same behavior as my Back soft button, thinking that the Back hard button will behave exactly like the former button (not finish B).
Now, getting back from B to A with Back hard key, everything is fine. At this point with the focus in A, when the user presses the back hard button again, the expected behavior is that the application leaves.
The problem is that expected behavior does not occur, given that B is still alive; so that overriden onBackPressed
in B is still listening, and some other behavior ocurr instead.
How can I finish listening with the overriden onBackPressed
in B, so that when the focus is in A the application leaves?
Thanks in advance.