In my first Activity I’m putting stuff into a Bundle and then firing off the Intent:
b = new Bundle();
b.putString(Constants.KEY_CLASS, classSelected);
Intent i = new Intent(this, AssessmentMarksActivity.class);
i.putExtras(b);
startActivity(i);
In the next Activity, I just get what I need from it:
tvClass = (TextView) findViewById(R.id.tvAssessmentClass);
b = getIntent().getExtras();
classSelected = b.getString(Constants.KEY_CLASS);
tvClass.setText(classSelected);
I get a NPE when I try to set the text of the TextView.
This is the XML for the Text View:
<TextView
android:id="@+id/tvAssessmentMarksClass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Class"
android:textSize="20dp" />
Seems the ids are not the same, thus causing your NPE.