目录

传递参数

    //新建一个显式意图,第一个参数为当前Activity类对象,第二个参数为你要打开的Activity类
    Intent intent =new Intent(MainActivity.this,MainActivity2.class);

    //用Bundle携带数据
    Bundle bundle=new Bundle();
    //传递name参数为tinyphp
    bundle.putString("name", "xiaomi");
    intent.putExtras(bundle);

    startActivity(intent);        

接收参数

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newtest);   

        //新页面接收数据
        Bundle bundle = this.getIntent().getExtras();
        //接收name值
        String name = bundle.getString("name");
       Log.i("获取到的name值为",name);     
    }