使用keySet()方法获取Bundle中的全部key,然后根据key依次遍历Bundle中的value。
代码如下:
public static void showBundleData(Bundle bundle) {
if (bundle == null) {
return null;
}
String string = "Bundle{";
for (String key : bundle.keySet()) {
string += " " + key + " => " + bundle.get(key) + ";";
}
string += " }Bundle";
}