title: passing String parameter using Intent in Android
body: <p>I am trying to parse a website that searches by content1 or content2 depending which button is clicked. I have an algorithm that works fine, but I was asked to make it in two classes. I hope it's not gonna make me change my whole algorithm. But yet, I am troubling sending string parameters to the new activity and I hated it.</p>
  
  <p>I defined global parameters:</p>
  
  <pre><code>String content1;
  String content2;
  </code></pre>
  
  <p>I need to get string in an EditText whose names are "namesurname" and "district":</p>
  
  <pre><code>content1 = district.getText().toString();
  content2 = namesurname.getText().toString();
  </code></pre>
  
  <p>I have two buttons that have listeners:</p>
  
  <pre><code>    search1.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent search = new Intent(FirstActivity.this, SecondActivity.class);
              search.putExtra("param_a", content1);
                      startActivity(search);
          }               
      });
      search2.setOnClickListener(new View.OnClickListener() {         
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Intent search = new Intent(AvukatParserActivity.this, ParserActivity.class);
              search.putExtra("param_b", content2);
          startActivity(search);
          }
      });
  </code></pre>
  
  <p>From now on, my SecondActivity.class shows up.</p>
  
  <p>I am trying to get intent in the new activity:</p>
  
  <pre><code>    Intent search = getIntent();
      String location = search.getStringExtra("param_a");
      String name_surname = search.getStringExtra("param_b");
  </code></pre>
  
  <p>Here's how I check my content1:</p>
  
  <pre><code>Toast.makeText(this, location, Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>It toastes as null as content2. No errors, no warnings. I don't get what I'm doing incorrect. Thanks in advance.</p>