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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:57:26+00:00 2026-05-15T17:57:26+00:00

I have an app that has a list as its main activity and then

  • 0

I have an app that has a list as its main activity and then you can click items which opens a detailed view of that item. I also have a search activity that is similar to the main activity and works as intended.

However I want this search activity to only have once instance on the stack so that users can search multiple times and clicking back would return them to the previouse view that they were on before they started searching (rather than go back to the previouse search results)

both the singleTask and singelInstance launch mode seems to do what I want so Im not sure which one I should be using for this purpose and why?

  • 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-15T17:57:27+00:00Added an answer on May 15, 2026 at 5:57 pm

    From the Application Fundamentals page of the Android dev guide:

    By default, all the activities in an
    application have an affinity for each
    other — that is, there’s a preference
    for them all to belong to the same
    task.

    A "singleInstance" activity stands
    alone as the only activity in its
    task. If it starts another activity,
    that activity will be launched into a
    different task regardless of its
    launch mode — as if
    FLAG_ACTIVITY_NEW_TASK was in the
    intent. In all other respects, the
    "singleInstance" mode is identical to
    "singleTask".

    As noted above, there’s never more
    than one instance of a "singleTask" or
    "singleInstance" activity, so that
    instance is expected to handle all new
    intents. A "singleInstance" activity
    is always at the top of the stack
    (since it is the only activity in the
    task), so it is always in position to
    handle the intent. However, a
    "singleTask" activity may or may not
    have other activities above it in the
    stack. If it does, it is not in
    position to handle the intent, and the
    intent is dropped. (Even though the
    intent is dropped, its arrival would
    have caused the task to come to the
    foreground, where it would remain.)

    4 Activities in a Task

    Since there is never more than one instance of the Activity with either launch mode, the back button will always take you to the existing instance of the Activity in your case.

    An important difference is that "singleTask" doesn’t require the creation of a new task for the new Activities being launched when something is selected. Nor will it have to remove that new task on the back button each time.

    Since your Activity stack does all pertain to one user "task", and it doesn’t sound like you have an intricate Intent structure where singleInstance may be beneficial to always handle them, I would suggest using the singleTask launch mode.

    Here is a good blog post for more info, as well as credited for the image: Android Activities and Tasks series – An introduction to Android’s UI component model

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

Sidebar

Related Questions

I have an app that has a list of menu items. When you click
I have an app that has a list of items. My customer prefers to
i have an app that has a few checkboxes in the settings and then
I have built a small app that has a JSlider which controls the speed
I have a web app that has a Diary. In this Diary, I can
Have an app that has listings - think classified ads - and each listing
I have an app that has a centre view with two views off to
I have an app that has a tabbar at the bottom. When I select
I have an app that has a TableView, NavigationView and TabBar running together. There
I have an app that has a mapview, and it shows 20 pins (from

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.