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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:48:03+00:00 2026-06-11T17:48:03+00:00

Here’s the issue. I have an application where I want to press a button,

  • 0

Here’s the issue. I have an application where I want to press a button, start a new activity that displays a list of items, allow the user to select any number of items, click submit and send that data to the original activity that called the new activity with the list of items. Here’s the basic structure:

Activity A -> Activity B (select items, press submit) -> [already running] Activity A (receive sent items)

I have no problem sending data back and forth. The problem that I do have is that when I try to restart Activity A, it goes through the Activity’s onCreate() method. I prefer not to do this because I want to be able to set up everything beforehand in the onCreate() method, then supplement what is already in there through the onRestart() method. I’m not exactly sure why the onCreate() method is being called every time I restart the activity. My guess is the way I call the activity in Activity B:

Intent intent = new Intent(this, PatientChartActivity.class);
intent.putExtra("checked", checked);
intent.putStringArrayListExtra("checked", checked);
startActivity(intent);

I have been looking at the Android activity lifecycle and I’m not sure why it is not automatically returning to the previous activity, unless I do indeed have to force it do do so. One thing that I am sure of is the the activity that is running is not being destroyed. I put in a Log.v(TAG, "DESTROY") log message in the onDestroy() method ensuring it doesn’t destroy the activity. I have tried using different flags when I start the activity to tell the system that I want to restore a previously started activity, but those don’t seem to work either. I may misunderstand them. I have researched exstensiveley on the topic but none of the solutions I found have helped. Here is an issue that I found that seems to be identical to mine
but didn’t seem to solve what I was looking for. I also looked at the following links for other possible routes of getting around the issue but did not work.

http://www.droidnova.com/use-intents-to-start-other-activities,76.html

http://www.warriorpoint.com/blog/2009/05/24/android-how-to-switch-between-activities/

  • 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-11T17:48:05+00:00Added an answer on June 11, 2026 at 5:48 pm

    What it is actually done according to the things you have stated(“Activity A -> Activity B (select items, press submit) -> [already running] Activity A (receive sent items)”) is:

    Activity A = new Instance -> going to Activity B = new Instance -> going to Activity A again = new Instance

    So your activity “stack” is actually 2 instances of activity A and one of activity B. That is why your second call in activity A initializes it and calls ‘onCreate()’ again. One of the solutions to the problem, and probably the best is:

    From activity A start the activity B with this method: ‘startActivityForResult()’. Then in activity B despite starting the activity A as you currently do, try setting a result back to activity A through this function: ‘setResult (int resultCode, Intent data)’ and then call ‘finish()’ in activity B. In activity A implement the ‘onActivityResult()’ method.

    I will now explain how the application lifecycle:

    • activity A is initialized and starts activity B waiting for a result in order to do “something” with it. So far so good.
    • activity B is initialized and after submit it does set a result for activity A. Then it finishes itself and automatically the result is passed to the previous activity.
    • activity A takes focus again, ALREADY INITIALIZED and the ‘onActivityResult()’ method is invoked. The ‘intent’ that was set in activity B and now is passed in activity B.

    Tell me if that helps and if you need some sample code.

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

Sidebar

Related Questions

Here is my code (Say we have a single button on the page that
Here is the issue I am having: I have a large query that needs
Here is the problem that I am trying to solve. I have two folders
here is how i call the following function: List<decimal> numbers = new List<decimal>(); numbers.Add(210m);
Here is my code...I have two dimensional matrices A,B. I want to develop the
Here's my scenario - I have an SSIS job that depends on another prior
here is my code, SiteMember class @OneToMany(mappedBy = member,cascade=CascadeType.ALL) private List<MemberThread> memberThread = new
Here is my scenario. I have a website running under AppPool1 and that works
Here is my problem.. I have the option to create(add) two new input fields,
Here's the code I have. It works. The only problem is that the first

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.