Data transfer between the activity of Android development

Source: Internet
Author: User

Set values by Putextra, get values by Getextra

Putextra need to set the key-value pair, Getextra by the corresponding key to get the passed value (directly between the Getextra plus the value type you want to get)

1. Open another activity in one activity through Startactivityforresult ()

2. This method usually receives two parameters, the first one is the intent object, the second is the Requestcode

3. In the first activity, rewrite the Onactivityresult method, by switch to determine the transmitted requestcode (which activity is passed back), usually also need to judge ResultCode (return result value), To perform the appropriate operation

4. In the activity that is opened, you can get the data passed in by Getintent (). Getextra

5. Finally, you can return data via Setresult to the activity that opened it by using a button setting in the activity that was opened.

6. The method has two parameters, the first is the ResultCode, the second is the intent object, and then the finish () drop can show the activity that opened it.

Data transfer between the activity of Android development

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.