Not knowing your exact requirements, itβs hard to give you an exact answer, but you can use tasks to achieve what you need. If you have 3 actions with names A, B, and C. If you set C so that there are different taskAffinity tags in the manifest - A and B, then C. uses a separate back stack. If you then set clearTaskOnLaunch="true" for A in the manifest, then the back stack will clear when the user leaves this task. Thus, the application launch activity is launched by the user. The user presses the button that launches B. If the user now presses the "Back" button, they return to A. If from B the user presses the button to launch C, then the back task stack for A and B is cleared, and if the user drops back, they return to A.
A full explanation of this can be found in Affinity Handling and Back Stack Clearing .
source share