title: How to do an if statement in an onCreate method of a new activity?
body: <p>I was wondering if anyone could help me with a problem I'm having with if statements in the onCreate method. I'm making a button that passes information on to another activity and then that activity will display the information based on if statements I setup in the onCreate method code. Now I was looking around for information on "How to do if statements in onCreate methods?" and <a href="https://stackoverflow.com/questions/22112660/oncreate-method-with-if-else-condition">found this question</a> about it. So, I change my code to make it similar to the code used in the answer but I keep getting an "App stopping working" error message on my tablet. So, I was wondering if anyone could help me and tell me if I coded something wrong or if I need to pass the information to the new activity a different way? or if I need to add anything to the code that I missing?</p>
  
  <p>Thank you in advance!</p>
  
  <p><strong>My code</strong></p>
  
  <p>Main Activity: (code in onclick method)</p>
  
  <pre><code> if (select == 2) {
              Intent ShowIntent = new Intent(MainActivity.this, results.class);
              ShowIntent.putExtra("SN", select);   // int
              ShowIntent.putExtra("IN1", IN1T);   // string
              ShowIntent.putExtra("D1", D1T);    // string
              ShowIntent.putExtra("Qty1", M1);   // int
              ShowIntent.putExtra("U1", U1T);   // string
              ShowIntent.putExtra("IN2", IN2T); // string
              ShowIntent.putExtra("D2", D2T);  //string
              ShowIntent.putExtra("Qty2", M2); // int
              ShowIntent.putExtra("U2", U2T); // string
              startActivity(ShowIntent);
          } else {
              Toast.makeText(getApplicationContext(), "Not working...", Toast.LENGTH_LONG).show();
          }
  </code></pre>
  
  <p>new activity (updated code - 7/19 5:06)</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.results);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          ValueS = (TextView) findViewById(R.id.txtselectv);
          welcome = (TextView) findViewById(R.id.txtWelcome);
          start =(TextView) findViewById(R.id.txtStarted);
          INR = (TextView) findViewById(R.id.txtIN1R);
          DR = (TextView) findViewById(R.id.txtD1R);
          QTYR = (TextView) findViewById(R.id.txtQty1R);
          UR = (TextView) findViewById(R.id.txtU1R);
          INR2 = (TextView) findViewById(R.id.txtIN2R);
          DR2 = (TextView) findViewById(R.id.txtD2R);
          QTYR2 = (TextView) findViewById(R.id.txtQty2R);
          UR2 = (TextView) findViewById(R.id.txtU2R);
  
          Bundle extras = getIntent().getExtras();
          select = extras.getInt("SN", 0);
          passSN = String.valueOf(select);
          ValueS.setText(passSN);
  
          if (passSN.equals("2")){
  
              INR.setVisibility(View.VISIBLE);
              DR.setVisibility(View.VISIBLE);
              QTYR.setVisibility(View.VISIBLE);
              UR.setVisibility(View.VISIBLE);
              INR2.setVisibility(View.VISIBLE);
              DR2.setVisibility(View.VISIBLE);
              QTYR2.setVisibility(View.VISIBLE);
              UR2.setVisibility(View.VISIBLE);
  
              pIN1 = extras.getString("IN1");
              pD1 = extras.getString("D1");
              pU1 = extras.getString("U1");
              pIN2 = extras.getString("IN2");
              pD2 = extras.getString("D2");
              pU2 = extras.getString("U2");
  
              INR.setText(pIN1);
              DR.setText(pD1);
              pM1 = extras.getInt("Qty1", 0);
              passM1 = String.valueOf(pM1);
              QTYR.setText(passM1);
              UR.setText(pU1);
              INR2.setText(pIN2);
              DR2.setText(pD2);
              pM2 = extras.getInt("Qty2", 0);
              passM2 = String.valueOf(pM2);
              QTYR2.setText(passM2);
              UR2.setText(pU2);
          } 
  
          }
  
      }
  </code></pre>
  
  <p><strong>Any ideas?</strong></p>
  
  <p><strong>Update: My problem is solved</strong> (Explain in answer post)</p>