米脂
要将数据从您的活动中获取到您的意图,请将其添加为:Intent intent = new Intent(this, MyIntent.class);intent.putExtra("aString", aString);intent.putExtra("aSomething", customSerializableType);startActivityForResult(intent, MY_REQUEST_ID);在意图中得到它:public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... Intent intent = getIntent(); String newString = intent.getStringExtra("aString"); CustomSerializableType newSomething = intent.getSerializableExtra("aSomething");}根据您的意图发回数据:private void done() { Intent intent = new Intent(); intent.putExtra("aString", aString); intent.putExtra("aSomething", customSerializableType); setResult(Activity.RESULT_OK, intent); finish();}并在托管活动中获取这些数据@Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case MY_REQUEST_ID: if (resultCode == Activity.RESULT_OK) { String newString = data.getStringExtra("aString"); CustomSerializableType newSomething = data.getSerializableExtra("aSomething"); } break;}