title: Crash while sending data between Activities
body: <p>So, I'm basically fooling around with some kind of login form, and trying to say a customized hello with the user name on the upcoming activity. The code compiles with no problem but the app crashes as soon as I click on the login button, the login worked successfully before I tried to implement the customized hello, so the problem has to be somewhere in the following code.</p>
  
  <p>Here is where I call the activity:</p>
  
  <pre><code>Intent k = new Intent(this, MainActivity.class);
              //Sends login name to activity k
              k.putExtra("loginName", login.getText().toString()); 
   //login is the EditText variable name for the login text field
              startActivity(k);
  </code></pre>
  
  <p>Here is where I retrieve the extra data and try to use it as described:</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.widget.TextView;
  
  public class ProfileActivity extends Activity {
  
      TextView helloString;
  
      @Override
      public void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.home);
          Bundle extras = getIntent().getExtras();
  
          //Getting the hello text string
          helloString = (TextView)findViewById(R.id.textHello);
          String loginName = extras.getString("loginName");
          helloString.setText("¡Hello, " + loginName + "!");
  
      }
  
  }
  </code></pre>
  
  <p>It somehow avoids the crash if I put in comment these two lines:</p>
  
  <pre><code>String loginName = extras.getString("loginName");
  helloString.setText("¡Hello, " + loginName + "!");
  </code></pre>
  
  <p>Still, I can't be sure if the problem is really there or not, I thought it could have something to do with the type of data sent from the first activity not matching with the type being retrieved on the second, but still got no clue after trying some stuff around that.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Editing:</p>
  
  <p>I actually found out that I may have something to do with the fact that I am calling to mainActivity.class while the text is being shown in an activity called profileActivity.class, the problem is, profileActivity is being shown as a tab inside the mainActivity so I don't really know how should I approach that.</p>
  
  <p>Editing 2:</p>
  
  <p>So I solved it finally myself, for anyone interested I just sent the data to the MainActivity.class</p>
  
  <pre><code>Intent k = new Intent(this, MainActivity.class);
  
              //Sends login name to activity k
              k.putExtra("loginName", login.getText().toString());
              startActivity(k);
  </code></pre>
  
  <p>And, inside the Main Activity, when calling the ProfileActivity to set it up as a tab:</p>
  
  <pre><code>//Profile tab
              intent = new Intent(this, ProfileActivity.class);
              Bundle extras = getIntent().getExtras();
              intent.putExtra("loginName", extras.getString("loginName"));
              spec = mTabHost.newTabSpec("home")
                      .setIndicator("Home", res.getDrawable(R.drawable.profile_icon))
                      .setContent(intent);
              mTabHost.addTab(spec);
  </code></pre>
  
  <p>Problem solved, thanks for the help everyone anyways.</p>