0
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
}
Dileep Patel
  • 1,988
  • 2
  • 12
  • 26
vishal patel
  • 294
  • 2
  • 4
  • 13
  • https://developer.android.com/training/basics/intents/result.html – rookieDeveloper Oct 20 '16 at 05:12
  • By the help of android startActivityForResult() method, we can get result from another activity.Check out this link for sample http://www.javatpoint.com/android-startactivityforresult-example – AbhayBohra Oct 20 '16 at 05:17

2 Answers2

21

When we start another activity from current activity to get the result for it, we call the method startActivityForResult(intent, RESPONSE_CODE);. It redirects to another activity like opens camera, gallery, etc. After taking image from gallery or camera then come back to current activity first method that calls is onActivityResult(int requestCode, int resultCode, Intent data). We get the result in this method like taken image from camera or gallery.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
iasoftsolutions
  • 251
  • 2
  • 4
2

lets say you are writing the new whatsapp. you have the activity responsible for creating the message, then you want to add the recipient and to do this you launch the activity responsible for this with startActivityForResult

this activity go fullscreen and you have the list of your contacts and you select one of this. this activity closes and you are back on the previous one.

onActivityResult is the callback you have on the first activity to grab the contacts you choose