54.9 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 answerQuestion() method, which is called when the “Answer Question” 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 answerQuestion(View view) {
finish();
}
@Override
public void finish() {
Intent data = new Intent();
EditText editText1 = findViewById(R.id.editText1);
...