启动浏览器活动后显示以前的活动?

发布于 2025-01-05 09:53:32 字数 422 浏览 3 评论 0原文

我有一个场景,我的应用程序有一系列活动,然后打开浏览器活动。然后,浏览器活动对用户进行身份验证并回调具有自定义方案的 URL,即 myapp://finished。

意图过滤器用于触发现有活动之一的显示。我基本上希望应用程序返回到浏览器活动启动之前显示的活动。

我遇到的问题是浏览器活动创建了一个新任务,因此当浏览器回调并加载我的活动时,会在浏览器任务中创建它的新实例,而不是我应用程序的原始任务。这导致我的活动被重新创建。

任务(由我的应用程序创建)

1) 活动1

2) 活动2

任务(由浏览器创建)

3) 浏览器活动

4)活动2(新实例)

我知道有一些标志可用于恢复现有活动而不是重新创建它们,但它们不能像浏览器限制在浏览器任务堆栈之后创建的任何新意图一样工作。

I'm got a scenario where my app has a series of activities and then opens a Browser activity. The browser activity then authenticates the user and calls back to a URL with custom scheme i.e. myapp://finished.

An intent filter is used to trigger the display on one of the existing activities. I basically want the app to go back to the activity that was displayed before the Browser activity was launched.

The problem I'm having is that the Browser activity creates a new task so when the browser calls back and my activity is loaded a new instance of it is created in the browsers task and not my app's orignal task. This results in my activity being recreated.

Task (created by my app)

1) Activty 1

2) Activty 2

Task (created by the browser)

3) Browser Activity

4) Activity 2 (new instance)

I'm aware that there are flags that can be used to resume existing activities instead of recreating them but they don't work as any new intent that is created after the browser is restricted to the browsers task stack.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失而复得 2025-01-12 09:53:32

我想在被 webview 调用后完成该活动将会弹出堆栈上的最后一个活动。

I guess by finishing the activity just after getting invoked by webview will pop up your last activity on the stack.

生生漫 2025-01-12 09:53:32

您是否使用 Webview 或启动第 3 方浏览器?在最后一种情况下,考虑使用 Webview

Are you using a Webview or launching a 3rd party browser? In the last case, consider using a Webview

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文