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