javaandroidback-stack

Android Studio Java pop an Activity from Backstack based on a condition in next activity


I have a case where I need to pop an activity from backstack based on a condition in the next activity. Say there are 3 activities A, B & C.

Activity A has a list and when user taps on a specific item activity B starts with a form that has many items. User fills the form(partial or complete) and can preview the same in activity C. Inside activity C he can confirm the details or simply go back to activity B and continue working on the form. What I want is activity B popped out of backstack if user taps "confirm" in activity C and pressing back button should take user to activity A instead of B.

Any help will be appreciated


Solution

  • You should start Activity C for result https://developer.android.com/training/basics/intents/result from Activity B

    And then in situation when you want go back from C-> A you have to