-1

i am wanting to Trigger a event on the old activity when returning back from the newer activity.

so when i hit the Done button and im using Finish(); to return back to the old Activity this works but i need to update the ui on the old activity. do i set up for a OnActivityResultListener? and handle it that way? im not exactly sure how to set that up but im sure there is plenty of info on that else were.

shizhen
  • 12,251
  • 9
  • 52
  • 88

1 Answers1

1

You should use below method to start your activity

static final int YOUR_REQUEST_CODE = 1;  // The request code
startActivityForResult(yourIntent, YOUR_REQUEST_CODE);

And then, in the OLD activity, override below method:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == YOUR_REQUEST_CODE) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {

            // Do something with here.
        }
    }
}

More details can be found at Android Developer Official Guide

shizhen
  • 12,251
  • 9
  • 52
  • 88