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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:46:54+00:00 2026-05-30T04:46:54+00:00

Scenario: First activity starts seconds activity with startActivityForResult Second activity starts third activity with

  • 0

Scenario:

  1. First activity starts seconds activity with startActivityForResult
  2. Second activity starts third activity with startActivityForResult

Expected result:
Third (last) activity sets a result which is caught on the second activity’s onActivityResult

Current result:
Third (last) activity sets a result which is caught on the first activity’s onActivityResult

How can I set a result on the third activity which will be caught on the second activity’s Third (last) activity sets a result which is caught on the second activity’s onActivityResult?

Some code snippets:

First activity

public class TestProjActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.main);

    Log.i("TAAAG", "1st activity - startActivityForResult");
    Intent intent = new Intent(TestProjActivity.this, Activ2.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
    startActivityForResult(intent, 1008);
}

@Override  
protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    super.onActivityResult(requestCode, resultCode, data);
    Log.i("TAAAG", "1st activity - onActivityResult");
    if (resultCode == RESULT_OK) {  
        Log.i("TAAAG", String.valueOf(requestCode));
        switch (requestCode) {  
        case 1008:
            String info = data.getExtras().getString("KEY1");
            Log.i("TAAAG", "1st activity - onActivityResult - printing result");
            Log.i("TAAAG", info);
            break;
        }
    }
}

}

Second activity

public class Activ2 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i("TAAAG", "2nd activity - startActivityForResult");
    Intent intent = new Intent(Activ2.this, Activ3.class);

    startActivityForResult(intent, 1009);

    Intent intent2 = new Intent();
    intent2.putExtra("KEY1", "VALUE1");


    setResult(RESULT_OK, intent2);
    finish();
}

@Override  
protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    super.onActivityResult(requestCode, resultCode, data);
    Log.i("TAAAG", "2nd activity - onActivityResult");
    if (resultCode == RESULT_OK) {  
        Log.i("TAAAG", String.valueOf(requestCode));
        switch (requestCode) {  
        case 1009:
            String info = data.getExtras().getString("KEY2");
            Log.i("TAAAG", "2nd activity - onActivityResult - printing result");
            Log.i("TAAAG", info);
            break;
        }
    }
}

}

Third activity

 public class Activ3 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i("TAAAG", "3rd activity - Inserting Value and finishing");

    Intent intent = new Intent();
    intent.putExtra("KEY2", "VALUE2");

    setResult(RESULT_OK, intent);
    finish();
}

}

  • 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-30T04:46:56+00:00Added an answer on May 30, 2026 at 4:46 am

    I think You Should Remove finish(); in oncreate last line in Second activity….

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

Sidebar

Related Questions

Let me explain my scenario first: I have around 2000 tests to run, which
Here's the scenario: Start Activity A Activity A starts service S Service S runs
Here's scenario: I have 2 activities and one service First activity is a landing
here's my first! quick rundown: SCENARIO i'm creating an app in which you can
I'm facing a dilemma (!). In a first scenario, I implemented a solution that
Here's the scenario: if this is a user's first time logging into my web
So, Here is my scenario: I have two activity and one service --> all
My scenario: I am populating a ListView in an activity that is displaying a
I am trying to send the events from one Java class to Activity. Scenario
The scenario is first run an expensive sorted query and save the first 100,000

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.