(1)新建一个bundle类
Bundle bundle = new Bundle();
(2)bundle类中加入数据(key -value的形式,另一个activity里面取数据的时候,就要用到key,找出对应的value)
bundle.putString("Data", "data from TestBundle");
(3)新建一个intent对象,并将该bundle加入这个intent对象
Intent intent = new Intent();
intent.setClass(TestBundle.this, Target.class);
intent.putExtras(bundle);
在另外一个Activity的获取boundle中的数据
Intent intent=getIntent(); //得到intent对象
Bundle bundle=intent.getExtras();//得到intent对象传过来的数据
String unameString=bundle.getString("uname");//获取用户名
int pwd=bundle.getInt("pwd");//获取密码
TextView tView=(TextView)findViewById(R.id.tv1);
tView.setText(unameString+" "+pwd); //显示获取的数据