title: Filling a TextView with a Double from another class
body: <p>I have an application that gets your current location. It will return your current address, latitude and longitude. When you click convert it takes you to a new class. </p>
  
  <p>I want to get latitude and longitude (if it has something) into a textView in another class. </p>
  
  <p><strong>FIRST CLASS</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private static Button newWindowBtn; //new window button
  
  Button btnShowLocation;
  GPSTracker gps;
  Double latitude;
  Double longitude;
  String addressStr;
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              shareIt();
          }
      });
  
  
      final TextView address = (TextView)findViewById(R.id.textView);
  
      onClickButtonListener(); //NEW WINDOW CLICK LISTENER
  
      btnShowLocation = (Button) findViewById(R.id.show_location); //GPS BUTTON
  
      final Geocoder geocoder = new Geocoder(this,Locale.ENGLISH);
  
      btnShowLocation.setOnClickListener(new View.OnClickListener()
      { //GPS CLICK LISTENER
          @Override
          public void onClick(View v) { //SHOWS LOCATION
              gps = new GPSTracker(MainActivity.this);
  
              if(gps.canGetLocation()){
                  latitude =  gps.getLatitude();
                  longitude = gps.getLongitude();
  
  
                  try{
                      List&lt;Address&gt; addresses = geocoder.getFromLocation(latitude,longitude,1);
                      if(addresses != null)
                      {
                          Address returnedAddress = addresses.get(0);
                          StringBuilder strReturnedAddress = new StringBuilder("Address:\n");
                          for (int i = 0; i &lt; returnedAddress.getMaxAddressLineIndex();i++){
                              strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
                          }
  
  
                          address.setText(strReturnedAddress.toString() + "Latitude: " + latitude + "\nLongitude: " + longitude);
  
                          addressStr = strReturnedAddress.toString();
  
                      }
                      else
                      {
                          address.setText("No address returned");
                      }
                  }
                  catch(IOException e){
                      e.printStackTrace();
                      address.setText("Can't get address");
                  }
              }else{
                  gps.showSettingsAlert();
              }
          }
      });
  }
  </code></pre>
  
  <p><strong>SECOND CLASS</strong></p>
  
  <pre><code>public class secondActivity extends AppCompatActivity {
  
      Button convertBtn;
      TextView latitudeTxt;
      TextView longitudeTxt;
      TextView latitudeDMS;
      TextView longitudeDMS;
  
  
  
      convertTo convert = new convertTo();
  
      MainActivity mainActivity = new MainActivity();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_second);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  shareIt();
              }
          });
  
          convertBtn = (Button) findViewById(R.id.convertBtn);
  
          latitudeTxt = (TextView)findViewById(R.id.latitudeTxt);
          longitudeTxt = (TextView)findViewById(R.id.longitudeTxt);
  
          latitudeDMS = (TextView)findViewById(R.id.latitudeDMS);
          longitudeDMS = (TextView)findViewById(R.id.longitudeDMS);
  
  
  
          convertBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
              }
          });
      }
  </code></pre>
  
  <p>So I would want <code>latitudeTxt</code> to have the latitude from the previous screen (first class). I'm a student and trying to learn. </p>
  
  <p>I've tried adding this to the first class:</p>
  
  <pre><code>secondActivity secondActivity = new secondActivity();
  secondActivity.latitudeTxt.setText(latitude);
  </code></pre>
  
  <p>This didn't work.</p>
  
  <p>I tried in the second class</p>
  
  <pre><code>MainActivity mainActivity= new MainActivity();
  latitudeTxt.setText(mainActivity.latitude);
  </code></pre>