Android的不同的Activity之间的数据传递,类似于桌面软件开发中不同窗体间的数据传递。
android通过bundle对象来传递数据
Activity1:
文件名:Form1.java
Intent intent = new Intent();
intent.setClass(Form1.this, Form2.class);
Bundle bundle = new Bundle();
bundle.putDouble("param1", 176);
bundle.putString("param2", 'hello');
intent.putExtras(bundle);
startActivity(intent);
Activity2:
文件名:Form2.java
Bundle bundle = this.getIntent().getExtras();
String sex = bundle.getString("param1");
double height = bundle.getDouble("param2");