TL;DR Use Activity.startActivityForResult
Long answer:
You should start by reading the Android developer documentation. Specifically the topic of your question is covered in the Starting Activities and Getting Results
section of the Activity
documentation.
As for example code, the Android SDK provides good examples. Also, other answers here give you short snippets of sample code to use.
However, if you are looking for alternatives, read this SO question. This is a good discussion on how to use startActivityForResults
with fragments, as well as couple othe approaches for passing data between activities.