android中的bundle使用
1 Bundle介绍 Bundle主要用于传递数据;它保存的数据,是以key-value(键值对)的形式存在的。 我们经常使用Bundle在Activity之间传递数据,传递的数据可以是boolean、byte、int、long、float、double、string等基本类型或它们对应的数组,也可以是对象或对象数组。当Bundle传递的是对象或对象数组时,必须实现 Serializable 或Parcelable 接口。下面分别介绍Activity之间如何传递基本类型、传递对象。 2传递基本类型 Bundle提供了各种常用类型的putXxx()/getXxx()方法,用于读写基本类型的数据。Bundle操作基本数据类型的API表格如下所示: 写数据的方法如下: // "com.test" is the package name of the destination class// "com.test.Activity02" is the full class path of the destination classIntent intent = new Intent().setClassName("com.bundletest", "com.bundletest.Bundle02"); Bundle bundle = new Bundle();bundle.putString(