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 8249053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:24:18+00:00 2026-06-07T23:24:18+00:00

I really don’t understand how all this flags working since I do exactly what

  • 0

I really don’t understand how all this flags working since I do exactly what the doc said, and it didn’t solved my problem. My activity is launching like this : (first) Activity A -> Activity B -> (second) Activity A. If I press button back, it goes back to Activity B -> Activity A -> Exit application. Now I want from second Activity A stated from Activity B, when press back, it will skip Activity B and first Activity A, and Exit application right away. Here’s the code:

From A to B:

TabActivityGroupAbs parentActivity = (TabActivityGroupAbs) ((Activity) ctx).getParent();
detailIntent = new Intent(parentActivity, B.class);
parentActivity.startChildActivity("BFromA", detailIntent);

From B to A:

TabActivityGroupAbs parentActivity = (TabActivityGroupAbs) ((Activity) ctx).getParent();
detailIntent = new Intent(parentActivity, A.class);
detailIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
detailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
parentActivity.startChildActivity("AFromB", detailIntent);

From B to A, I add the flags FLAG_ACTIVITY_CLEAR_TOP. But it didn’t clear anything. When I pressed back, it still went to Activity B, and then A again. What did I do wrong?

And it seems like none of the flags are working at all. From A to B, I put:

detailIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

It supposed to prevent B be put to activity stack. But it’s not. From the second activity A, it still go back to B when press back.

Now what should I do to exit application and not go back to B from the second activity A.

EDIT: I forgot to mention. From B to A, if I called finish() to kill activity B, then from second activity A, when press back, it go back to first activity A. Why activity A have 2 instance here though I set FLAG_ACTIVITY_CLEAR_TOP? Really strange.

  • 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-07T23:24:21+00:00Added an answer on June 7, 2026 at 11:24 pm

    You can use the following methods to start and close child activity

    public ArrayList<String> mIdList;
    /**
     * Starts an Activity as a child Activity to this.
     * 
     * @param Id
     *            Unique identifier of the activity to be started.
     * @param intent
     *            The Intent describing the activity to be started.
     * @throws android.content.ActivityNotFoundException.
     */
    public void startChildActivity(String Id, Intent intent) {
        Window window = getLocalActivityManager().startActivity(Id,
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
        if (window != null) {
            mIdList.add(Id);
            setContentView(window.getDecorView());
        }
    }
    
    /**
     * This is called when a child activity of this one calls its finish method.
     * This implementation calls {@link LocalActivityManager#destroyActivity} on
     * the child activity and starts the previous activity. If the last child
     * activity just called finish(),this activity (the parent), calls finish to
     * finish the entire group.
     */
    @Override
    public void finishFromChild(Activity child) {
        LocalActivityManager manager = getLocalActivityManager();
        int index = mIdList.size() - 1;
    
        if (index < 1) {
            finish();
            return;
        }
    
        manager.destroyActivity(mIdList.get(index), true);
        mIdList.remove(index);
        index--;
        String lastId = mIdList.get(index);
        Intent lastIntent = manager.getActivity(lastId).getIntent();
        Window newWindow = manager.startActivity(lastId, lastIntent);
        setContentView(newWindow.getDecorView());
    }
    

    Example:

    startChildActivity("Merchants", new Intent(this,MerchantScreen.class));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really don't understand this. I have a simple ASP with 3 div in
I really don't understand what I'm doing wrong, but according to Adobe, this is
I really don't get why this is not working. I want to avoid a
I have this problem and really don't know how to solve this. I'm having
I've got a strange problem and really don't understand what's going on. I made
I really don't understand why this function doesn't work: function GetNomRepertoireTemporaire:WideString; var PathLocal :
I really don't know how to say, may be this is why I didn't
I use this code to get Server Date but I really don't understand.CreateDateTime() is
I really don't understand this. I downloaded the recent version of xCode 3.2.5 and
I really don't understand regex at all, and it hurts my head. I've 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.