I'm working on an Android application that starts from an activity that serves as the menu screen (I'll call this activity the menu activity).
There is a button that moves the app to another activity where the user can enter their name (I'll call this activity the name activity), and then the app returns to the menu activity.
After entering my name, (I have now gone like this: menu - name - menu) when I press the back button, it goes back to the name activity, with the name still present in the EditText field.
I'd like to know if there's some way to change the back key's functionality to avoid going to the name activity, and instead return to the main activity (The hierarchy is - main - menu - name).
Also, is there some way I can prevent the name from being retained in the EditText?
Thanks in advance.
I'm a bit confused by the hierarchy but either way this is what you're looking for if you want to clear any previous activities: Clearing Activity Backstack
Otherwise call
finish()
on the Activity you want to close before changing. That will clear the EditText