有时android中的setResult()无法将正确的结果代码传递给另一个Activity



这是我的代码,

if (onApply) {
Intent intent = new Intent();
setResult(200, intent);
super.onBackPressed();
} else {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
super.onBackPressed();
}

不是每次都这样,但有时我会在onActivity结果中得到结果代码0。

提前谢谢。

通常,您可以忽略某处调用finish((而不调用setResult((的情况。

顺便说一句,RESULT_CANCELD=0是默认值,因为从未调用过setResult((。

最新更新