title: Passing extras between activities in android
body: <p>I'm trying to pass a string as an extra, but for some reason it just isn't going through. Here's my code:</p>
  
  <pre><code>public void setChordMajor(View v){
      chordType = "major";
      Intent intent = new Intent(this, ChordView.class);
      intent.putExtra("CHORD", chordType);
      startActivity(intent);
  }
  </code></pre>
  
  <p>CHORD is defined:</p>
  
  <pre><code>public final static String CHORD = "com.example.musiciansreference.EXTRA_CHORD";
  </code></pre>
  
  <p>And it is received by the next activity:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_chord_view);
  
      Intent intent = getIntent();
      chordType = intent.getStringExtra(Chords.CHORD);
  
      TextView textView = new TextView(this);
      textView.setTextSize(40);
      textView.setText(chordType);
  
      setContentView(textView);
  }
  </code></pre>
  
  <p>Which just displays a blank screen. Somehow the string is not getting sent! </p>
  
  <p>EDIT: I think the problem is in the second activity's ability to display the chord... here is the full code:</p>
  
  <pre><code>import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.view.Menu; 
  import android.view.MenuItem;
  import android.widget.TextView;
  
  public class ChordView extends ActionBarActivity {
  
  
  
  String chordType = "null";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_chord_view);
  
      Intent intent = getIntent();
      chordType = intent.getStringExtra(Chords.CHORD);
  
      TextView textView = new TextView(this);
      textView.setTextSize(40);
      textView.setText(chordType);
  
      setContentView(textView);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.chord_view, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>