I have activity A that starts activity B which starts activity C:
A -> B -> C
When a user clicks on a button in activity C, I want to bring A to the top of the stack and take B & C completely out of the stack. Is there a way to do this?
Explanation. finish() − It is used to close the activity. finish(int requestCode) − It is used to close the activity with requestCode.
Use finishAffinity() to clear all backstack with existing one. Suppose, Activities A, B and C are in stack, and finishAffinity(); is called in Activity C, - Activity B will be finished / removing from stack. - Activity A will be finished / removing from stack. - Activity C will finished / removing from stack.
Activity: represents the presentation layer of an Android application, e.g. a screen which the user sees. An Android application can have several activities and it can be switched between them during runtime of the application.
You can use the FLAG_ACTIVITY_CLEAR_TOP flag on the intent to restart activity A.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With