Passing data to an action

To send data from one action to another you need to use extras on intents


In the first action add this

public void passdata(View view) {
String myText = “Some Text”;
// Do something in response to button
Intent myIntent = new Intent(this, Two.class);
  myIntent.putExtra(“name_of_data_to_retreive”, myText (The string or variable to send);



Then in the action you need the data in onCreate.

Intent intent = getIntent();
        String MyVariable= intent.getExtras().getString(“name_of_data_to_retreive“);


The string is now inside MyVariable


Now see setting the text within a view for one use of this method