Android development Bundle usage, android development bundle

Source: Internet
Author: User

Android development Bundle usage, android development bundle

In android development, we often need to transmit data between two activities. The most common method is to useintent.putXXX()But in many cases, we will also:

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

These two methods are very similar. View them today.intent.putXXX()The method source code is found as follows:

    /**     * Add extended data to the intent.  The name must include a package     * prefix, for example the app would use names     * like "".     *     * @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     * into a single statement.     *     * @see #putExtras     * @see #removeExtra     * @see #getBooleanArrayExtra(String)     */    public Intent putExtra(String name, boolean[] value) {        if (mExtras == null) {            mExtras = new Bundle();        }        mExtras.putBooleanArray(name, value);        return this;    }

Yes, you are not mistaken,intent.putXXX()The method is to first create a bundle and then use the bundle to pass the value. From this we can see that the intent has all the APIs for value passing, but some intents in the bundle do not necessarily have them. That is to say, the value passing function of the bundle is more powerful.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger. I am very grateful if you have any mistakes.

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: 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.