直接上代码

 Intent intent = new Intent();
 intent.setClass(MainActivity.this, Test1Activity.class);
 intent.putExtra("str", "come from first activity");
 startActivity(intent);

在另一个Activity中接受参数

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

  Intent intent = getIntent();
  Bundle bundle = intent.getExtras();
  String str = bundle.getString("str");

}

相关文章:

  • 2021-08-27
  • 2021-10-28
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-02-05
  • 2021-11-28
猜你喜欢
  • 2021-10-22
  • 2021-04-02
  • 2021-11-23
  • 2022-12-23
  • 2021-11-27
  • 2021-10-04
  • 2021-11-26
相关资源
相似解决方案