can anybody tell what is use of start activity for result in android
This question already has an answer here:
By calling startActivityForResult
with Activity2
, your current activity will be notified when the Activity2
is finished (back button pressed), and this way you can also get information from it.
This notification you can catch by overriding your activity's onActivityResult
method.
This article about Android startActivity and startActivityForResult might be worth to look at.
startActivityForResult()
allows you to start activity and get some data back. Imagine that you have some file picker activity. You can start it and when user chooses the file, the result is given back to the original activity.
Also, it can be used if you simply want to ensure that the second activity has successfully done somethings.
The result code is obtained in onActivityResult method:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Result OK.d.
if (requestCode == resultCode) {
// do something good
}
}
链接地址: http://www.djcxy.com/p/52484.html