title: how to pass values from different activities to another activity
body: <p>I am writing my first Android app.</p>
  
  <p>I want to input 3 integers in the activity A, and do the same in activities B and C. Then I want to calculate something with all 9 integers and display the result in activity D.</p>
  
  <p>How can I get the integers from the first 3 activities into the last activity?</p>
  
  <p>EDIT:
  I have tried it for two Activity..the integer in input from MainActivity and the output is print in TextView in Activity 2...But the answer in Activity 2 is always is zero.</p>
  
  <p>Code is :-</p>
  
  <p>public class MainActivity extends ActionBarActivity {</p>
  
  <pre><code>int int1;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Button b = (Button) findViewById(R.id.bt1);
      EditText et = (EditText) findViewById(R.id.edT1);
      try{
      int1 = Integer.parseInt(et.getText().toString());
      } catch (NumberFormatException e)
      {
          e.printStackTrace();
      }
      b.setOnClickListener(new OnClickListener(){
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Intent i = new Intent(MainActivity.this,Activity2.class);
              i.putExtra("val1",int1);
              startActivity(i);
  
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And for Activity 2 is :-</p>
  
  <pre><code>public class Activity2 extends Activity {
  
  int value;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity2xml);
      TextView t2 = (TextView) findViewById(R.id.tt2);
      Intent intent = getIntent();
      int a = intent.getIntExtra("val1",0);
      t2.setText("Bingo "+String.valueOf(a));
  
  }
  </code></pre>
  
  <p>}</p>