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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:50:42+00:00 2026-05-20T10:50:42+00:00

I am finding it hard to understand how the Android behaves with tasks and

  • 0

I am finding it hard to understand how the Android behaves with tasks and activities and need a solution on this one particular problem of mine.

I have a TabActivity A with singleTask as launchMode in manifest, and is the launcher as well. This internally starts two other Activities B, C upon visiblity(or clicks) of respective tabs. Now considering that activity B was started along with A, the task back stack becomes
Task 1 [ A B ]

I also happen to run a Service (X) in background. After sometime, on some event, Service X opens a new Activity D ( which is not part of the tab activity’s specs ). Activity D is specified launchMode as singleTask and affinity different than the package. Since services can directly start the activities, I had to provide FLAG_ACTIVITY_NEW_TASK. All goes well and the activity D is created and displayed.

With the explainations from developer.android.com about the tasks creation and all, the new Activity D should be created in a new task of its own. Thus the whole viewpoint should look like

[Background Task 1 [ A B ]][Foreground Task 2 [ D ]]

Now there is a way provided in activity D to go to Activity A and the intent flag is set to FLAG_ACTIVITY_CLEAR_TOP.

With my understanding, this flag should clear all the activities above A that are in the task of which A is the root activity. Meaning it should destroy activity B only. i.e. the viewpoint should look like
[Background Task 2 [ D ]] [Foreground Task 1 [ A ]]

But in my case, it is destroying activity D as well, which is definetly not the behaviour i want since i want the Acitivity D to be present all the time unless explicitly finished by user. After navigating, the stack looks like
[Foreground Task 1 [ A ]].

Am I doing something wrong here? If the above behavior is the expected one in Android, then is there a way where I can start A from D without clearing D but finishing all other activities between A & D?

  • 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-20T10:50:43+00:00Added an answer on May 20, 2026 at 10:50 am

    The problem turned out to be two declarations of Activity D in AndroidManifest.xml.
    Removed the extra declarations and its now working perfectly.

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

Sidebar

Related Questions

I'm having difficulties finding a hard definition of the word test case. Some sources
I'm learning OpenGL and having a hard time finding a clear definition of the
I have little working knowledge of python. I know that there is something called
I'm having an issue finding out how to calculate an average over x days.
I know you can use @ to suppress errors. But is there anyway you
I am trying to use a TCP socket to communicate a shared state between
I am developing an app using data from google reader's API and using GData
i would think that a delete would be pretty simple, I haven't been able
So I've been looking into using google base for a clients job listing project.

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.