gpt4 book ai didi

android - 从已经完成的 Activity 调用 Activity.setResult()

转载 作者:行者123 更新时间:2023-11-30 00:32:57 26 4
gpt4 key购买 nike

我正在尝试在我的 Android 应用程序中实现深度链接。

我的用例是,当用户点击深层链接 url,然后选择我的应用程序进行付款时,我的应用程序的 ActivityA 被打开(启动器 Activity ),然后在完成 ActivityA,从那里我的 ActivityB 被打开,从那里,在完成 ActivityB 之后,ActivityC 被打开。现在,在 ActivityC 中付款后,我想调用 setResult() 方法,以便将付款数据发送回之前的应用程序。

我的问题是 ActivityA 已经完成,我如何调用 setResult() 以发送回响应?

此外,我正在完成 ActivityAActivityB,因为当用户按下后退按钮时,我不希望我的用户返回到这些 Activity 。

最佳答案

Intent.FLAG_ACTIVITY_FORWARD_RESULT是在 ActivityAActivityB 然后到 ActivityC 之间导航时需要应用的 Intent 标志。来自 docs :

If set and this intent is being used to launch a new activity from an existing one, then the reply target of the existing activity will be transfered to the new activity. This way the new activity can call setResult(int) and have that result sent back to the reply target of the original activity.

关于android - 从已经完成的 Activity 调用 Activity.setResult(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43952757/

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