Search code examples
androidandroid-activity

Detect that an activity has closed in Android


In my application I need to launch a SelectionActivity to select one of the options. Once the option has been selected I need to refresh another list on the MainActivity.

This is the code that I use to launch the SelectionActivity:

Intent intent = new Intent(MainActivity.this, SelectionActivity.class);
startActivity(intent);

In SelectionActivity this is the code that receives the selected option an closes the activity:

selectedValue = adapter.getItem(position);
finish();

Now the application comes back to MainActivity but I don't know how to receive an event that the SelectionActivity has closed.

Thanks


Solution

  • Look into startActivityForResult()