Activity不调用onActivityResult()方法的原因

问题描述:


在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

你可能感兴趣的:(Activity不调用onActivityResult()方法的原因)