Use of the bundle for Android development

Source: Internet
Author: User

In Android development, we often need to pass data between two activity, the most common is used intent.putXXX() , but many times we will do so:

Bundle bundle = new Bundle();bundle.putXXX()...

These two kinds of values are similar, look at the intent.putXXX() method source code today, and find this:

    /** * ADD Extended data to the intent. The name must include a package * prefix, for example the app com.android.contacts would use names * like "Com.and     Roid.contacts.ShowAll ".     * * @param Name The name of the extra data, with package prefix.     * @param value The boolean array data value.     * * @return Returns The same Intent object, for chaining multiple calls * to a single statement. * * @see #putExtras * @see #removeExtra * @see #getBooleanArrayExtra (String) */      PublicIntentPutExtra(String name,Boolean[] value) {if(Mextras = =NULL) {Mextras =NewBundle (); } mextras.putbooleanarray (name, value);return  This; }

Yes, you are not mistaken, the intent.putXXX() method is actually the first new bundle out, and then use the bundle to pass the value. This can be seen in the intent on the value of the interface bundle, but there are some intent in the bundle is not necessarily, that is, the bundle of the value of the function more powerful.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. If there is a wrong place, I would appreciate it if I could criticize it.

Use of the bundle for 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.