title: Passing extras between activities and forwarding them to a single activity
body: <p>My app is a basic login app that at the end will present all values user input for the fields in other activities. I am working with intent objects and flags. The activities use:</p>
  
  <ul>
  <li>intent extras to store the key-values,</li>
  <li>FLAG_ACTIVITY_FORWARD_RESULT </li>
  <li>startActivityForResult() and onActivityForResult() methods   </li>
  </ul>
  
  <p>So, activities named as AActivity, BActivity, Caactivity and the navigation flow must be: A → B → C → A with results from B and C.</p>
  
  <p>My understanding with the logic of the code is that this tells Android that activity 3 should forward its result back to the activity that called activity 2, which is activity 1 in this case. And also when activity 3 sets its result and finishes, onActivityResult()in activity 1 will be called with the result data sent from activity 3.</p>
  
  <p>However, when I run the app, I get the results from only activity 3, but receive null from activity 2, which is displayed in TextView in activity 1 as null,null,valueC,valueC, as shown in the picture.
  <a href="http://i.stack.imgur.com/QvVux.png" rel="nofollow">click for the image</a></p>
  
  <p>I googled and searched for the similar issues arised, yet couldn't solve the problem.</p>
  
  <p>Thank you in advance for your help</p>
  
  <p>Here are my codes:</p>
  
  <p>AActivity:</p>
  
  <pre><code>public class AActivity extends AppCompatActivity {
  
  private static final int REQUEST_CODE = 1;
  
  Button btnStart;
  TextView userDetails;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_a);
  
      userDetails = (TextView) findViewById(R.id.userdetails);
      btnStart = (Button) findViewById(R.id.btnstart);
  
      btnStart.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent activityAIntent = new Intent(AActivity.this, BActivity.class);
              startActivityForResult(activityAIntent, REQUEST_CODE);
          }
      });
  }
  
  
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if ((requestCode == REQUEST_CODE) &amp;&amp; (resultCode == RESULT_OK)) {
  
          String return_userName = data.getExtras().getString("username");
          String return_userPassword = data.getExtras().getString("password");
          String return_secretQuestion = data.getExtras().getString("secretquestion");
          String return_secretAnswer = data.getExtras().getString("secretanswer");
          userDetails.setText("Your details: " + return_userName + "," + return_userPassword +
                  "," + return_secretQuestion + "," + return_secretAnswer);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>BActivity:</p>
  
  <pre><code>public class BActivity extends AppCompatActivity {
  
  EditText userName,userPassword;
  Button btnCancel,btnNext;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_b);
  
      userName=(EditText)findViewById(R.id.username);
      userPassword=(EditText)findViewById(R.id.userpassword);
      btnCancel=(Button)findViewById(R.id.btncancel);
      btnNext=(Button)findViewById(R.id.btnnext);
  
      btnCancel.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent_back_to_a = new Intent(BActivity.this,AActivity.class);
              startActivity(intent_back_to_a);
          }
      });
  
      btnNext.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent activityCIntent = new Intent(BActivity.this,CActivity.class);
              activityBIntent.putExtra("username",userName.getText().toString());
              activityBIntent.putExtra("password",userPassword.getText().toString());
              intent_to_c.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
              startActivity(activityBIntent);
              finish();
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>CActivity:</p>
  
  <pre><code>public class CActivity extends AppCompatActivity {
  
  EditText secretQuestion, secretAnswer;
  Button btnCancel,btnNext;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_c);
  
      secretQuestion =(EditText)findViewById(R.id.secretquestion);
      secretAnswer =(EditText)findViewById(R.id.secretanswer);
      btnCancel =(Button)findViewById(R.id.btncancel);
      btnNext =(Button)findViewById(R.id.btnnext);
  
      btnCancel.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent_back_to_a = new Intent(CActivity.this,AActivity.class);
              startActivity(intent_back_to_a);
          }
      });
  
      btnNext.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent data = new Intent(CActivity.this,AActivity.class);
              data.putExtra("secretquestion",secretQuestion.getText().toString());
              data.putExtra("secretanswer",secretAnswer.getText().toString());
  
              setResult(RESULT_OK,data);
              finish();
          }
      });
  }
  </code></pre>
  
  <p>}</p>