英文:
Start external Activity as a separate task
问题
我有一个使用launchMode
为singleTask
的单一活动的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:
<intent-filter>
<action android:name="com.example.action.ACTIVATE_TOKEN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
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--->B--->A--->B
or
A---startActivityForResult--->B---startActivityForResult--->A---setResult--->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
<activity
android:name=".YourActivity"
android:launchMode="standard">
</activity>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论