54.8 Returning Data from a Sub-Activity
ActivityB is now launched as a sub-activity of MainActivity, which has, in turn, been modified to handle data returned from ActivityB. All that remains is to modify ActivityB.java to implement the finish() method and to add code for the returnText() method, which is called when the “Return Text” button is touched. The finish() method is triggered when an activity exits (for example when the user selects the back button on the device):
public void returnText(View view) {
finish();
}
@Override
public void finish() {
Intent data = new Intent();
EditText editText2 = findViewById(R.id.editText2);
...