gpt4 book ai didi

android - 无历史记录和 child Activity 结果

转载 作者:太空宇宙 更新时间:2023-11-03 13:05:15 25 4
gpt4 key购买 nike

我有以下情况:

Activity A -> Activity B (noHistory set) -> Activity C

当 C 完成时,我需要将 C 的结果返回给 A。可能吗?

我能做到这一点的唯一方法是保留 B 的历史记录并通过它转发 C 的结果。因此,尽管如此,如果启动 B 并且程序从后台恢复,则将显示 B。我希望 B 不保留在堆栈中。

最佳答案

其他详细信息

enter image description here

在 Activity A 中:

Intent intent = new Intent(getActivity(), B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivityForResult(intent, REQUEST_CODE);

在 Activity A 中:

public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
// TODO
}
}

在 Activity B 中:

Intent intent = new Intent(getActivity(), C.class);
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent);

在 Activity C 中:

Intent intent = new Intent();
// put something to intent
setResult(Activity.RESULT_OK, intent);
finish();

关于android - 无历史记录和 child Activity 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5962255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com