問題描述:
在Activity中采用startActivityForResult(intent, requestCode)方式激活AnotherActivity.
當AnotherActivity執行:
Intent intent=new Intent();
intent.putExtra("test", "hello");
setResult(RESULT_OK, intent);
finish();
此時在該Activity中並未執行和調用onActivityResult方法:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
錯誤原因:
在Activity中執行startActivityForResult(intent, requestCode)時requestCode必須大於等於0