A Activity 启动 B Activity : Intent intent = new Intent(this,B.class); startActivityForResult(intent,1);B Activity 传值,并关闭B Activity:Intent intent = new Intent();intent.putExtra("KEY",value);setResult(RESULT_OK,intent);finish();A Activity 接收值:重新写 onActivityResultpublic void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); String construction = data.getStringExtra("KEY");}
结束当前Activity时将值传给上一个Activity
最新推荐文章于 2022-04-08 23:00:19 发布