Activity --- data exchange between activities, data transmission between activities
Main functions:
A main interface (main Activity) can be connected to many different sub-function modules (Child Activity). After the sub-module completes the tasks, it will return to the main interface, it may also return data completed by some sub-modules to the main Activity for processing. The callback function onActivityResult is required for such data exchange.
<1> startActivityForResult (IntentIntent, int requestCode );
The first parameter: an Intent object
Second parameter: If> = 0,RequestCode when Activity endsWill be returned in onActivityResult. To determine the Activity from which the returned data is returned
<2> onActivityResult (int requestCode, int resultCode,IntentData)
First Parameter: This integerRequestCode is providedOnActivityResult is used to determine the Activity from which the returned data is returned.
This requestCode andIn startActivityForResultRequestCode corresponds.
Second Parameter: This integerResultCode is composedThe child Activity is returned through its setResult () method.
Third Parameter: An Intent object with returned data.
<3> setResult (Int resultCode,IntentData)
Call this method to return the data returned by the Activity to the parent Activity.
The first parameter:When Activity endsResultCodeWill be returned in onActivityResult,Generally, it is RESULT_CANCELED and RESULT_ OK.
The second parameter:An Intent object that is returned to the parent Activity.