1

I am fairly new to android and I am confused right now about two things that I have noticed and read online. When I start a new intent / activity, it seems that I am allowed to go back to the previous activity with the back button which means two things to me.

1) The previous activity is not destroyed and kept alive somewhere or

2) it's destroyed and every time I click the back button it creates a new intent of the previous activity

Now, here is my problem, according to all the guides I've seen so far, in order to send data from one activity to another activity I have to create a new intent and use the putextra function . My question is whether this process also works for the reverse when I want to send data from the newly created activity back to the previous activity.

Here is a portion of the relevant code :

Home screen code:

public void CreateNewCueCardSet(View view){
    // Create a new page/activity when button is clicked
    Intent NewCueCardPage = new Intent(this, NewCueCardActivity.class);
    startActivity(NewCueCardPage);
}

//NewCueCardActivity.class

public void createSet(View view){
    // this will save text input from user on the activity 
    EditText setType = (EditText) findViewById(R.id.editText);
    EditText setName = (EditText) findViewById(R.id.editText2);
    //How do I send these 2 variable's data back to the home screen? 
}

I am thinking that I just create a new intent of the home screen and send it, but what if the home screen is not destroyed and kept somewhere in memory. What do I do in that case to gain access to it?

Belphegor
  • 1,683
  • 4
  • 23
  • 44

0 Answers0