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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:09:50+00:00 2026-06-07T07:09:50+00:00

I have two apps, which I will refer to as app A and app

  • 0

I have two apps, which I will refer to as app A and app B. App B is a single task app and normally, if you start this app from the Home screen and use the Back button, you will not be allowed to return to the Home screen. Now suppose app A needs to call app B using an Intent. If the user then uses the Back button in app B, I really do want them to return to app A. But since I am overriding the Back button, it is not possible to return to app A using the Back button.

How can I return to app A but make sure app B remains running if it was running when app A called it? If app B was not running when app A called it, app B should shutdown (get destroyed) when the Back button is pressed.

I am using Android 2.2

UPDATE:

I tried the following:

  @Override
  public void onBackPressed()
  {
    try
    {
      if (this.returnToClient)
        moveTaskToBack (true);

      this.returnToClient = false;
    }
    catch (Exception ex)
    {
    }
  }

I set returnToClient to true if the activity is launched by a calling app by checking some bundle data that gets passed in.

Now if I press the Back button, app B will move to the background and app A comes to the foreground. Looks good. Now if I press the Home button and then launch app B, app B just picks up where it left off. Also good. Now the bad part. If I do a long press on the Home button to bring up the history list and then tap on the icon for app B, the onNewIntent method gets called exactly the same with and with the same data being passed in as though app A had initiated the activity. So what I am guessing is that Android treats launching an app from the Home screen different than it does from the History list. Why? I have no idea. It seems that the history has to do with whoever launched the activity last and persists the bundle data as part of that history. That is weird and it results in unwanted behavior making app B look like it just got called from app A.

  • 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-07T07:09:52+00:00Added an answer on June 7, 2026 at 7:09 am

    Have AppA launch AppB using an Intent with an EXTRA that indicates that it was launched from AppA, something like this:

    Intent intent = new Intent(this, AppB.class);
    intent.putExtra("returnToAppA", "true");
    startActivity(intent);
    

    Then, when AppB traps the “back” key, it can check if it was launched from AppA and if so, it can return to appA like this:

    Intent intent = new Intent(this, AppA.class); // Use the starting
                                                  //  (root) Activity of AppA here
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    

    Setting FLAG_ACTIVITY_NEW_TASK will ensure that a new instance of AppA will not be created, but it will just return to the existing task containing AppA.

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

Sidebar

Related Questions

my end goal is to have two apps, a main app (which will do
I have two PHP apps which have twho class with the same name. -
I have two apps, both of which force the user to use the iPhone
I have two QT apps. One app can be considered to hold a big
I have two Express.js apps running on my server. A plain vanilla app called
I have two apps. which current run in two different ports. script1.js: var express
I have a need of implementing two apps that will exchange data with each
I have two apps which have same name and same functions. One in android
I have two apps between which I want some data exchanged. As they are
I have two applications communicating via RMI, a slave server (of which there will

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.