title: How do i send multiple Integers to a new activity?
body: <p>I have a way that I know is not the best way of sending them over rite now but I'm sending them as strings and converting them to an Int on the reciver side, the problem is when I do the conversion it crashes on my phone. This is what I have on my sender side:</p>
  
  <pre><code>    public void sendMessage(View view) {
      // Do something in response to button
      Intent intent = new Intent(this, PayTracker.class);
      // hourly wage send
      EditText editText = (EditText) findViewById(R.id.hourly_wage);
      String message1 = editText.getText().toString();
      intent.putExtra(MESSAGE_1, message1);
      // ot wage send
      EditText editText1 = (EditText) findViewById(R.id.ot_wage);
      String message2 = editText1.getText().toString();
      intent.putExtra(MESSAGE_2, message2);
      // hours per day send
      EditText editText2 = (EditText) findViewById(R.id.hours_day);
      String message3 = editText2.getText().toString();
      intent.putExtra(MESSAGE_3, message3);
      // start new activity
      startActivity(intent);
  </code></pre>
  
  <p>And this is what is on my reciving side:</p>
  
  <pre><code>    @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_pay_tracker);
      getActionBar().setDisplayHomeAsUpEnabled(true);
      // Receive messages from options page
      Intent intent = getIntent();
      String message1 = intent.getStringExtra(Options.MESSAGE_1);
      String message2 = intent.getStringExtra(Options.MESSAGE_2);
      String message3 = intent.getStringExtra(Options.MESSAGE_3);
      // convert string to integer
      int HW = Integer.valueOf(message1);
      int OTW = Integer.valueOf(message2);
      int HPD = Integer.valueOf(message3);
  </code></pre>
  
  <p>Ive tested everything and its the conversion that is causing the app to crash, i was hoping somebody could help me make it not crash or give me a whole new way sending an int to my second activity insted of sending a string and converting it.
  Thank you!</p>
  
  <p>=======================================================================</p>
  
  <p>Here is my new code with all your help!</p>
  
  <p>Sending:</p>
  
  <pre><code>    public void sendMessage(View view) {
      // Do something in response to button
      Intent intent = new Intent(this, PayTracker.class);
      // Gather text from text boxes
      EditText editText = (EditText) findViewById(R.id.hourly_wage);
      EditText editText1 = (EditText) findViewById(R.id.ot_wage);
      EditText editText2 = (EditText) findViewById(R.id.hours_day);
      //Create String from text
      String message1 = editText.getText().toString();
      String message2 = editText1.getText().toString();
      String message3 = editText2.getText().toString();
      //Convert String to Int
      int HW = 0, OTW = 0, HPD = 0;
      try{
          HW = Integer.valueOf(message1);
          OTW = Integer.valueOf(message2);
          HPD = Integer.valueOf(message3);
      }
      catch(NumberFormatException nfe){
          //do something else here
          //for e.g. initializing default values to your int variables
      }
      // Send Integers to PayTracker.java
      intent.putExtra(MESSAGE_HW, HW);
      intent.putExtra(MESSAGE_OTW, OTW);
      intent.putExtra(MESSAGE_HPD, HPD);
      // start new activity
      startActivity(intent);
  }
  </code></pre>
  
  <p>Receiving side:</p>
  
  <pre><code>    @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_pay_tracker);
      getActionBar().setDisplayHomeAsUpEnabled(true);
      // Receive messages from options page
      Intent intent = getIntent();
      int HW = intent.getIntExtra(Options.MESSAGE_HW, 0);
      int OTW = intent.getIntExtra(Options.MESSAGE_OTW, 0);
      int HPD = intent.getIntExtra(Options.MESSAGE_HPD, 0);
      // set textview
      TextView textView = (TextView) this.findViewById(R.id.yourpay);
      textView.setText(String.valueOf(HW));
  }
  </code></pre>