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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:12:38+00:00 2026-05-23T04:12:38+00:00

after looking up the ‘Defining launch modes’ section of the ‘Tasks and Back Stack’

  • 0

after looking up the ‘Defining launch modes’ section of the ‘Tasks and Back Stack’ guide , I dont understand exactly the behavior of an activity declared with “singleTask”.

assume that I start a singleTask-activity (via startActivity method ) when there is an instance of that activity laying at the bottom(root activity) of a background task,

as the article describes, the Intent I use to start singleTask-activity will be delivered to the instance, in this case, does the instance bring itself to top of its task and its task to foreground, or just bring its task to foreground without bringing itself to top of its task?

Do I make myself clear? pls help! thanks in advance

  • 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-23T04:12:39+00:00Added an answer on May 23, 2026 at 4:12 am

    I was/am having the same question actually.
    After reading replies here on stackoverflow and doing some experiments, I believe that when a singleTask activity is launched while it’s already in a background task, the system will kill all other activities at the top of the stack and resume the singleTask activity.

    For sure, this is not what I got out of the documentation though.

    Here is my theory:

    Launch Modes: Activity A: singleTask , Activity B: standard

    experiment 1

    • Launch A ; stack: [A]
    • Launch B from A; stack: [A|B]
    • Press home; stack: [A|B]
    • Launch A from launcher; Stack: [A] (onDestroy was called on B
      before onResume() on A)

    experiment 2

    • Launch A ; stack: [A]
    • Launch B from A; stack: [A|B]
    • Launch A from B; stack: [A] (onDestroy was called on B
      after onResume() on A)

    In my case, I had to use android:alwaysRetainTaskState="true" although this is not ideal as I do want the stack to be cleared after, say, 10 minutes as this recommendation makes sense:

    If the user leaves a task for a long
    time, the system clears the task of
    all activities except the root
    activity. When the user returns to the
    task again, only the root activity is
    restored. The system behaves this way,
    because, after an extended amount of
    time, users likely have abandoned what
    they were doing before and are
    returning to the task to begin
    something new.

    from the Tasks and Back Stack guide.

    I hope this helps other people.

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

Sidebar

Related Questions

After looking at other questions related to sharing solutions between VS 2005 and VS
After looking at another question on SO ( Using NaN in C++ ) I
After looking on MSDN, it's still unclear to me how I should form a
After looking around (for not terribly long I have to admit) I wonder if
After looking at RescueTime for windows/mac, it seems that there's a version for linux
After looking a while other google, and the web, I decided to post my
I have a query that is dynamically built after looking up a field list
Hmm, sounds easy enough but after looking at the ones that come with StringTemplate,
I am in the process of writing a text editor. After looking at other
Right now I'm using a JTable for what I'm doing. After looking through 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.