What Is Use Of Start Activity For Result In Android?
Solution 1:
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.
Solution 2:
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:
@OverrideprotectedvoidonActivityResult(int requestCode, int resultCode, Intent data) {
// Result OK.d.if (requestCode == resultCode) {
// do something good
}
}
Post a Comment for "What Is Use Of Start Activity For Result In Android?"