要求 将 Activity A中的数据传到C;
跳转为 Activity A-B-C
利用 Bundle 进行数据传值 节省代码
//A类 进行跳转时 相关的代码
Bundle bundle = new Bundle();
bundle.putString("key_1","1111111111111111111111");
bundle.putString("key_2","222222222222222222222");
bundle.putString("key_3","333333333333333333333");
bundle.putString("key_4","444444444444444444444");
Intent intent = new Intent(A.this, B.class);
intent.putExtra("bundle",bundle);
startActivity(intent);
//B类
Intent i = getIntent();
Bundle bundle = i.getBundleExtra("bundle")
bundle.putString("key_5","555555555555555555555555555");
//B类 进行跳转时 相关的代码
Intent intent = new Intent(B.this, C.class);
intent.putExtra("bundle",i.getBundleExtra("bundle"));
startActivity(intent);
//C类 接受数据
Intent i = getIntent();
Bundle bundle = i.getBundleExtra("bundle");
//根据Key 得到对应的值
String key_1=getString("key_1");
String key_2=getString("key_2");
String key_3=getString("key_3");
String key_4=getString("key_4");
String key_5=getString("key_5");
//=============================================================
个人认为
Bundle 与 Intent 本质是一样的;
Bundle 具有封装性可以节省代码