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 com.android.contacts would use names * like "com.android.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 * 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.