将数据"aa","bb"从MainActivity 传递 给 AActivity接收
一.在 MainActivity 中的发送代码
btnSend =(Button) findViewById(R.id.btnSend );
btnSend .setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, AActivity.class);
String data1="aa";
String data2="bb";
Bundle bundle = new Bundle();
bundle.putString("data1", data1);
bundle.putString("data2", data2);
intent.putExtras(bundle);
startActivity(intent);
}
});
二.在AActivity中接收代码
@Override
protected void onCreate(Bundle savedInstanceState) {
Bundle bundle = this.getIntent().getExtras();
String data1=bundle.getString("data1");
String data2=bundle.getString("data2");
}