如何通过已经运行的Activity切换到正在运行的Activity
我知道有很多关于此的讨论,但我无法使其正常工作。
Activity
(A) = singleTop
并且可以接收 android.intent.action.SEND
Activity
(B) = singleTask
当我从 Android 图库中选择一张图片并使用 (A) 打开它
(A) 将意图重定向到 (B)。
这工作正常,如果我按 HOME 并从午餐器中选择 (A) (B) 被带到前面。这就是我想要的,用户可以继续查看图片,
现在,如果我按 HOME 并再次打开 Android Gallery,则 (A) 是onRestart()
、OnStart()
和 onResume()
。我看到了(A)。
这是我喜欢切换到(B)的问题,因为用户需要完成他正在做的事情。
我看不出有什么好方法来做到这一点,为什么 Android Gallery 会恢复 (A)?
自从打开 Android Gallery 给我带来的可能是我做错了什么 (A)
任何帮助将不胜感激
I know there are much discussions about this but i cannot get this to work properly.
Activity
(A) = singleTop
and can receive android.intent.action.SEND
Activity
(B) = singleTask
When i from the Android Gallery select a picture and open it with (A)
The (A) is redirecting the intent to (B).
This is working ok and if i press HOME and select (A) from the luncher
the (B) is brought to front. That is what i want and user can continue with picture,
Now, if i press HOME and open the Android Gallery again the (A) isonRestart()
, OnStart()
and onResume()
. and i see (A).
This is the problem i like to switch to (B) because user need to finish what he was doing.
I cannot see a good way to do that and why does the Android Gallery resume (A)?
Maybe i do something wrong since opening the Android Gallery bring me (A)
Any help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是基于问题中有限信息的可能推理,假设 A 在其 onCreate() 中将意图重定向到 B。
1) 打开图库,选择一张图片,用 A 打开,将其重定向到 B
2) 按 home,从启动器中选择 A
3) 按 home,然后打开图库
在这种情况下,您可以尝试从 A 的 onStart() 重定向意图或者没有 B 作为 singleTask。
This is possible reasoning based on limited info in the question, assuming A is redirecting the intent to B in its onCreate().
1) Open Gallery, select a picture, open with A, redirect it to B
2) Press home, select A from launcher
3) Press home, and open gallery
This being the scenario, you can try redirecting the intent from A's onStart() or do not have B as singleTask.
更新
我知道这是一个复杂的场景。我通过在 (B) 启动后简单地杀死 (A)/finish() 来制定一个可行的解决方案。现在,
如果我按 HOME 并再次打开 Android Gallery,我会看到 Android Gallery。
如果我按 HOME 并打开 A,我会看到 B。
如果我从 BI 回复,请查看画廊
UPDATE
I know this is an intricate scenario. I have made a working solution by simply killing (A)/finish() after the launch of (B). Now,
if i press HOME and open the Android Gallery again i see Android Gallery.
if i press HOME and open A i see B.
if i press back from B I see the gallery