Here, the second parameter is the requestCode, it is required as you may call different activities from activity A, and those activities return their respective results, so when you use onActivityResult(), you can check from which activity you received the result using the requestCode.
Now, in Activity B, you can send data back like this-
And if you don't want to send data back, just don't putExtra in the intent and instead of RESULT_OK, the first parameter will be RESULT_CANCALED in the setResult.
Now, you can receive the result in Activity A by using onActivityResult method-
If you have any problems using startActivityForResult, do comment or contact me.