1。Activity A 向 Activity B里传数据
在Activity A写以下代码
Intent intent=new Intent(A.this,B.class);
Bundle bundle=new Bundle();
bundle.putString(“hello”);
intent.putExtra(bundle);
在Activity B写以下代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*获取Intent中的Bundle对象*/
Bundle bundle = this.getIntent().getExtras();
/*获取Bundle中的数据,注意类型和key*/
String name = bundle.getString("hello");
}
Activity 关闭使用finish()方法