title: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)'
body: <pre><code>enter code here
  public class MainActivity extends AppCompatActivity {
  TextView tv;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setTextInTextView();
      setContentView(R.layout.activity_main);
  
  }        
  public void setTextInTextView(){
      tv = (TextView) findViewById(R.id.rate);
      Bundle extra = getIntent().getExtras();
      tv.setText(""+extra.getString("key"));   
  }
  
  public void go(View view) {
      Intent i = new Intent(MainActivity.this,Activity2.class);
      startActivity(i);
  }
  enter code here
  public class Activity2 extends AppCompatActivity {
  RatingBar rb;
  float str;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_2);
      rb = (RatingBar)findViewById(R.id.rt);
  
  
  }
  
  public void submit(View view) {
     String st = String.valueOf(rb.getRating());
     Intent i = new Intent(Activity2.this,MainActivity.class);
     i.putExtra("key",""+st);
     startActivity(i);
  }
  }
  </code></pre>
  
  <p>I am a beginner to Android App Development. I am trying to send rating from Second Activity to mainActivity using intent. While doing that i am getting error: "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null"</p>