Bundle主要用于传递数据;它保存的数据,是以key-value(键值对)的形式存在的。
我们经常使用Bundle在Activity之间传递数据
存储
Intent intent = new Intent().setClassName(“com.bundletest”, “com.bundletest.Bundle02”);
Bundle bundle = new Bundle();
bundle.putString(“name”, “skywang”);
bundle.putInt(“height”, 175);
intent.putExtras(bundle);
startActivity(intent);
取出
Bundle bundle = this.getIntent().getExtras();
String name = bundle.getString(“name”);
int height = bundle.getInt(“height”);
后续补充