title: Sending Data From One Activity to Another Without Creating a new Intent Android
body: <p>i have an impending question that is mind buggling me at the moment in regards to android app development.</p>
  
  <p>In my app, which works exactly the way i want it to, except for one part i have problem figuring out is how will i send a piece of data from one activity to another without making a new Intent.</p>
  
  <p>In my Code, the user inputs his Name, Mass, and Height, and when the user clicks on Button calculate, it takes all the values in a new intent to a second activity, there, it calculates the BMI of the user. <strong>Now, i want to send this freshly calculated BMI back to the First activity without creating a new intent</strong> but i am now sure on how to go about that</p>
  
  <p>Here are the relevant part of my Code</p>
  
  <p><strong>Main Activity.java</strong></p>
  
  <pre><code>package mobileapp.melvin.bmicalculator;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.os.Bundle;
  import android.view.*;
  import android.content.*;
  import android.widget.*;
  
  public class MainActivity extends Activity {
  
  public String name,mass,height,bmi;
  public EditText nameField, massField, heightField;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      bmi = getIntent().getStringExtra("BMI");
  
      //Create "TextFields" By getting ID of Editviews from Main XML
      nameField = (EditText) findViewById(R.id.mText_box1);
      massField = (EditText) findViewById(R.id.mText_box2);
      heightField = (EditText) findViewById(R.id.mText_box3);
  
      //Button To calculate and display BMI as TextViews
      Button launchBtn = (Button) findViewById(R.id.mButton_calculate);
      launchBtn.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              //Check is The "Textfields" have values
              if(!verifyData()){
                  return;
              }
              /*Create a new Intent to Launch another activity 
               * To display all the Values gotten from
               * The TextFields as Normal Text Values
               */
              Intent launcher = new Intent(v.getContext(),BMI1.class);
              //This intent then passes these values over to the next Intent
              launcher.putExtra("Name", name);
              launcher.putExtra("Mass", mass);
              launcher.putExtra("Height", height);
              //We then start this new activity with the new Intent
              startActivity(launcher);
          }
      });
  }
  </code></pre>
  
  <p>and <strong>BMI1.java</strong></p>
  
  <pre><code>package mobileapp.melvin.bmicalculator;
  
  import android.app.*;
  import android.content.*;
  import android.os.*;
  import android.view.*;
  import android.widget.*;
  
  public class BMI1 extends Activity {
  
  String name,mass,height,bmi;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_bmi1);
  
      //Get data from the first activity through intent
       name = getIntent().getStringExtra("Name");
       mass = getIntent().getStringExtra("Mass");
       height = getIntent().getStringExtra("Height");
  
       //convert mass and height to double and calculate BMI
       double m = Double.parseDouble(mass);
       double h = Double.parseDouble(height);
       bmi = Double.toString(calculateBMI(m, h));
  
      ((TextView) findViewById(R.id.b1_Label2)).setText(name);
      ((TextView) findViewById(R.id.b1_Label4)).setText(mass);
      ((TextView) findViewById(R.id.b1_Label6)).setText(height);
      ((TextView) findViewById(R.id.b1_Label8)).setText(bmi);
  
  
      Button backBtn = (Button) findViewById(R.id.b1Button_back);
      backBtn.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Intent launcher = getIntent();
              launcher.putExtra("BMI", bmi);
              finish();
          }
      });
  }
  
    private double calculateBMI(double toMass, double toHeight){
        double value;
  
        value = toMass/(toHeight * toHeight);
        return value;
    }
  
  }
  </code></pre>
  
  <p>I know there is no value passed because when a user clicks Display in the first Activity, it takes the values to a third Activity where a textView Should display For example <strong>"BMI: 20.66"</strong> but instead i get <strong>"BMI: null"</strong>, how will i fix this error?</p>