requestCode requestCode used to allocate the identifier for the request so that the request can be identified with this code in onActivityResult() . For example, if someone wrote codes to trigger two actions in action B and C, following the code
startActivityForResult(new Intent(A.this, B.class), 1); startActivityForResult(new Intent(A.this, C.class), 2);
now in onActivityResult() you can recognize which Activity returned the result.
The setResult() method is used to set a Intent to Result and a resultCode . Through resultCode we will tell onActivityResult() that the result is approved or canceled. in Intent , which we set to Result, can be used to transfer some data using the intent.putExtra() methods.
source share