Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:06:06+00:00 2026-06-03T13:06:06+00:00

in the process of building an app, I have an Activity lets call it

  • 0

in the process of building an app, I have an Activity lets call it A, and i open in multiple times, as A(1) -> A(2) -> A(3) -> … -> A(m) -> … -> A(n).

In the app I want to pop all the way back to A(m), is there a way to pop activities all the way back to a chosen one?

i already saw a few answers that had the FLAG_ACTIVITY_CLEAR_TOP but it seems to me like that is only to clear the whole stack and go to the first element in the stack and that is not what I’m trying to get.

update:

what I’m trying to achieve here is as follows: I have a list of questions, and the user can choose a different answer for each one.

once he chooses, the question and the answer go into a list of history, and another question is prompted. at any given point, the user can click a history button and go back to the question he chooses.

all the Q&A activities are the same, so going back to a question means popping the stack until getting there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:06:08+00:00Added an answer on June 3, 2026 at 1:06 pm

    If I understand you correctly you are saying that you have N number of the SAME activity and wish to go back to some arbitrary starting point activity in the stack?

    I am not totally clear on whether you know ahead of time that all activities forward of your “sticky” activity should be finished or if this is determined somewhere along the way

    I don’t know of any arbitrary way of popping N activities off the stack when they are duplicate activities but you could roll your own, such as (not finished code)

    If you know ahead of time that A(M) will be sticky before it launches the next activity(s) you could just tell each forward activity that it needs to kill itself once it launches it’s new task by passing it a flag then when the last activity in the chain ends you are back to A(M)

    in A(...) 
    startSelf()
    {
    
       Intent I = new Intent(this,MyActivity.class);
       if (bFinishSelf || bFinishForward) 
         I.putExtra("finishself", 1);
    
       if (Finishelf)  
         finish();
    
    
       startActivity(I); 
    
    in ... all A(...) onCreate( ... 
    
    Bundle b = getIntent().getExtras(); 
    if(b !=null && extras.getInt("finishself");
      bFinishSelf = true; 
    

    Then when you start a new activity check if the finishself flag is set and if so call finish() after starting new activity …

    If on the other hand A(z) is the one that determines you need to return to A(…) then I guess in A(z) you could tell the calling parent(s) that they need to kill themselves until reaching some ID contained in data …

    A(M)
    startActivityForResult(…)

    A(Z) somehow you determine that A(M) should be the sticky activity …

    finshAndStopAt(int ID) {
      Intent I = new Intent(); 
      I.putExtra("finish",ID); 
    
      if (getParent() == null) {
        setResult(Activity.RESULT_OK, I); 
      } else {
        getParent().setResult(Activity.RESULT_OK, I); 
      }
      finish();
    

    }

    All A(z … m) (parent’s) would monitor for the return data

    @Override void onActivityResult(int requestCode, int resultCode, Intent data) {
    
        // If we are asked to finish ourselves, pass it on ...    
        if (null != data && data.getInt("finish",stopAt) != myID) {
           if (getParent() == null) {
              setResult(Activity.RESULT_OK, data); 
           } else {
              getParent().setResult(Activity.RESULT_OK, data); 
           finish();
        }
        // else we can hang around and are the sticky activity
    }
    

    It’s a bit of pain and maybe someone knows of an easier method

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an automated deployment process for a Java app where currently I'm building
I'm in the process of building a sports team app and have created my
In the building process of an array I'm trying to call a function, checkIfNodeExists()
During the process of building software applications, you would start testing what you have
I am in the process of building my first iPhone app (xCode,objective-c) which has
I'm currently working on a cross-platform mobile app and have gone through the process
I am in the process of building a Rails app that will hook into
I am in the process of building a metro style app and I need
I'm in the process of building a mobile web app, and I've run into
I have a play application which I am in the process of building a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.