1.传递数据
eg:FirstActivity向SecondActivity传递数据
- FirstActivity主方法中
String data="hello kike";
Intent intent=new Intent(FirstActivity.this,SecondActivity.class);
intent.putExtra("extra_data",data);
startActivity(intent);
- SecondActivity主方法中
Intent intent=getIntent();
String str=intent.getStringExtra("extra_data");
Log.i("info","str="+str);
//如果返回Int类型的intent.getIntExtra("data",data);(如果没有返回的就返回data)