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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:48:47+00:00 2026-05-31T03:48:47+00:00

i have two sub activities apart from main activity. The sequence of calls go

  • 0

i have two sub activities apart from main activity.

The sequence of calls go like this.

Main –> Sub_Activity1 ,then Sub_Activity1 returns to Main Activity.
Main —> Sub_Activity2, then Sub_Activity2 returns to Main Activity.

But it is not happening. As far i can see only the 2nd sub activity is getting called, it is skipping the first one . but when i disable/comment out one of the sub activities the other one is working well. but when i want to call one after another it is calling only the second one. where am i going wrong. here is my code

Main Activity:

public void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    btn = (Button) findViewById(R.id.btn1);
    txt = (TextView) findViewById(R.id.textview1);
    txt.setText("hello world");
    in1= new Intent(TestActivity.this,Number.class);
    //startActivity(in1);
    startActivityForResult(in1, MY_DATA_CHECKCODE);


    in2= new Intent(TestActivity.this,Message.class);
    //startActivity(in1);
    startActivityForResult(in2, MY_DATA_CHECKCODE1);

}


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == MY_DATA_CHECKCODE) {


        num= data.getStringExtra("number");
        if(num!=null)
        txt.setText(num);

    }

    else if (requestCode == MY_DATA_CHECKCODE1) {


        num= data.getStringExtra("number");
        if(num!=null)
        txt.setText(num);

    }

}

subactivity1 and subactivity2 codes are same which are used to add some string data to a new intent which can be retrieved in the main intent.

                     number = et.getText().toString().trim();

            in= new Intent();

            //in.putExtras(b);
            in.putExtra("number", number);
            setResult(Activity.RESULT_OK,in);

i have changed the variables to use different request codes as well. they are MY_DATA_CHECKCODE and MY_DATA_CHECKCODE1.is there anything wrong in handling the return values in onActivitResult function.please give me ur suggestions to fix this problem. i have googled and but could not find proper solution for it.

  • 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-31T03:48:48+00:00Added an answer on May 31, 2026 at 3:48 am

    Android doc doesn’t say what happens if you call startActivityForResult twice.
    I think you should put the call to the second activity in the onActivityResult for the first one.

    At least this is the way I would do it

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

Sidebar

Related Questions

I have two columns say Main and Sub . (they can be of same
I have a query to select from another sub-query select. While the two queries
From the regular aspnet_Users table I have created two sub-tables with one to one
I have two classes, Main Sub In main class, i have a button and
I have two sub class that I need to copy a List element from
Intro: I have a LinearLayout, which contains two sub LinearLayouts, like so: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a domain like below. I have two sub-domains within that as below.
I have a main directory A with two sub directories B and C .
We have two projects basically, each of 2 these main projects have sub projects
Ok now i have two table categories and subcategories like this Categories: id title

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.