protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); } - developer.android.com/training/basics/intents/result.htmlrookieDeveloper– rookieDeveloper2016-10-20 05:12:41 +00:00Commented Oct 20, 2016 at 5:12
- By the help of android startActivityForResult() method, we can get result from another activity.Check out this link for sample javatpoint.com/android-startactivityforresult-exampleAbhayBohra– AbhayBohra2016-10-20 05:17:43 +00:00Commented Oct 20, 2016 at 5:17
2 Answers
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.
Comments
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