从已经完成的 activity 调用 Activity.setResult()
Call Activity.setResult() from activity which is already finished
我正在尝试在我的 android 应用程序中实施深层链接。
我的用例是,当用户点击深层链接 url,然后选择我的应用程序进行付款,然后我的应用程序 ActivityA
被打开(启动器 activity),然后完成ActivityA
,我的 ActivityB
从那里打开,完成后 ActivityB
,ActivityC
从那里打开。现在在 ActivityC
付款后我想调用 setResult()
方法以便将付款数据发送回之前的应用程序。
我的问题是 ActivityA
已经完成,我如何调用 setResult()
才能发回响应?
另外,我正在完成 ActivityA
和 ActivityB
,因为当用户按下后退按钮时,我不希望我的用户返回到这些活动。
Intent.FLAG_ACTIVITY_FORWARD_RESULT
is the intent flag you need to apply when you are navigating between ActivityA
to ActivityB
and then to ActivityC
. From 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 应用程序中实施深层链接。
我的用例是,当用户点击深层链接 url,然后选择我的应用程序进行付款,然后我的应用程序 ActivityA
被打开(启动器 activity),然后完成ActivityA
,我的 ActivityB
从那里打开,完成后 ActivityB
,ActivityC
从那里打开。现在在 ActivityC
付款后我想调用 setResult()
方法以便将付款数据发送回之前的应用程序。
我的问题是 ActivityA
已经完成,我如何调用 setResult()
才能发回响应?
另外,我正在完成 ActivityA
和 ActivityB
,因为当用户按下后退按钮时,我不希望我的用户返回到这些活动。
Intent.FLAG_ACTIVITY_FORWARD_RESULT
is the intent flag you need to apply when you are navigating between ActivityA
to ActivityB
and then to ActivityC
. From 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.