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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:55:36+00:00 2026-05-30T00:55:36+00:00

I think I’ve just found a really strange bug… But it can just be

  • 0

I think I’ve just found a really strange bug… But it can just be somekind of feature that I never heard of.

On my application if I have any Activity on the AndroidManifest with android:launchMode=”singleInstance” when you try to “clean” the stack to a certain point with the following code:

    Intent intent = new Intent(this, Xpto.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);

It goes to that activity. But when you press back, it returns to the previous.that should have been finished…

Example:

A -> B -> C

Then from C I call A with Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_CLEAR_TOP having A singleInstance on the Manifest. It goes to A but it only brings it to front. And does not finishes C and B.

Can somebody explain this behaviour?

The Xpto class I’m calling is at the time the root activity of the stack.

  • 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-05-30T00:55:39+00:00Added an answer on May 30, 2026 at 12:55 am

    from reading this thread:

    http://groups.google.com/group/android-developers/browse_thread/thread/5eb400434e2c35f4

    it seems that:

    “The currently running instance of activity B in the above example will
    either receive the new intent you are starting here in its onNewIntent()
    method, or be itself finished and restarted with the new intent. If it
    has declared its launch mode to be “multiple” (the default) and you have
    not set FLAG_ACTIVITY_SINGLE_TOP in the same intent, then it will be
    finished and re-created; for all other launch modes or if
    FLAG_ACTIVITY_SINGLE_TOP is set then this Intent will be delivered to
    the current instance’s onNewIntent(). ”

    which means that you need to set your launchMode to multiple instance, and use only FLAG_ACTIVITY_CLEAR_TOP.

    Intent intent = new Intent(this, Xpto.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    

    In the scenario you described, activity’s B and C are not finished when you start activity A (which is the root activity). The documentation describes that with launch mode of singleInstance and the flag FLAG_ACTIVITY_SINGLE_TOP set, activities B and C will NOT be finished. If you want to have activities B and C finished, then you must set the launch mode to multiple instance and NOT set the flag FLAG_ACTIVITY_SINGLE_TOP.

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

Sidebar

Related Questions

I think I know how to handle this case, but I just want to
I think that asking this might be kind of silly but I'm still wondering
I think I have found a bug when setting or getting the Me.Top property
I think I have a very popular problem, but not found answer for it
I think that I have a quite strange question. I am using a class
I think they are same thing but my boss say that is not right.
I think the file that is produced is an .asm file, any idea how
I think this is specific to IE 6.0 but... In JavaScript I add a
I think it can be done by applying the transformation matrix of the scenegraph
I think that java executables (jar files) are trivial to decompile and get the

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.