启动外部活动作为单独任务。

huangapple go评论145阅读模式
英文:

Start external Activity as a separate task

问题

我有一个使用launchModesingleTask的单一活动的Flutter应用程序。我已经将Google tap&pay SDK集成到我的应用程序中,它会在单击按钮时启动(startActivityForResult)一个单独的Activity。根据要求,我必须定义一个intent-filter来验证我的应用程序中的令牌。它看起来像这样:

<intent-filter>
  <action android:name="com.example.action.ACTIVATE_TOKEN"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

上述的intent-filter是我的Flutter应用程序的单一活动的一部分。现在,SDK的Activity具有一个动作,会再次调用我的应用程序(使用上述的action),我必须将验证结果发送回SDK的Activity。由于我的应用程序Activity是以singleTask模式启动的,SDK启动的Activity被销毁,不会等待结果返回。

流程大致如下:
A是我的应用程序的活动。B是SDK的活动。

A--->B--->A--->B


A---startActivityForResult--->B---startActivityForResult--->A---setResult--->B

我如何确保由SDK启动的Activity在我的应用程序通过intent-filter再次启动后仍然处于活动状态?

英文:

I have a Flutter app with Single Activity with launchMode as singleTask. I have integrated Google tap&pay SDK into my app which launches(startActivityForResult) a separate Activity on click of a button. As per the requirement I have to define an intent-filter to verify a token in my app. It looks something like this:

&lt;intent-filter&gt;
  &lt;action android:name=&quot;com.example.action.ACTIVATE_TOKEN&quot;/&gt;
  &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;/&gt;
&lt;/intent-filter&gt;

The above intent-filter is part of the Single Activity of my Flutter app. Now the Activity from the SDK have an action that will call my app(startActivityForResult) again with the above action and I have to send back the result after verification to the SDK's Activity. Since my app Activity is launched in singleTask the Activity launched by the SDK is killed and is not waiting for the result to be returned.

The flow looks something like this:
A is my app's Activity. B is the SDK's Activity.

A---&gt;B---&gt;A---&gt;B

or

A---startActivityForResult---&gt;B---startActivityForResult---&gt;A---setResult---&gt;B

How can I make sure that the Activity launched by the SDK is still active after my Activity is launched again through an intent-filter?

答案1

得分: 1

从您的Flutter应用程序的<activity android:name=".YourActivity" android:launchMode="standard">中删除singleTask启动模式。

英文:

Remove the singleTask launch mode from your Flutter app's

&lt;activity
    android:name=&quot;.YourActivity&quot;
    android:launchMode=&quot;standard&quot;&gt;  
&lt;/activity&gt;

huangapple
  • 本文由 发表于 2023年8月10日 11:54:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76872551.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定