Activity --- data exchange between activities, data transmission between activities

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.