Passing strings between activities in android

In your LocationActivity class:

Intent i = new Intent(this, FindAndroidActivity.class);
i.putExtra("KEY",YourData);

In FindAndroidActivity class

Bundle extras = getIntent().getExtras();
if(extras !=null) {
    String value = extras.getString("KEY");
}

Couple of scenarios:

  1. If you want to pass the string when you start the new activity, then add it to the starting Intent and retrieve it in the new activity's onCreate.
    Sending arrays with Intent.putExtra

    // Sending activity  
    String latLong = "test";  
    Intent i = new Intent(sendingClass.this, receivingClass.class);  
    i.putExtra("latLong", latLong);  
    startActivity(i);  
    
    // Receiving activity  
    Bundle extras = getIntent().getExtras();  
    String latLong = extras.getString("latLong");  
    
  2. If you want to pass the string when you return from an activity, then use startActivityForResult and implement the onActivityResult event
    http://micropilot.tistory.com/1577

  3. The 3rd scenario, passing the string between two activities running at the same time is not possible because only one activity can run (be in the foreground) at a time.