gpt4 book ai didi

android - 共享时 "FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET"的作用是什么?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:32:49 26 4
gpt4 key购买 nike

我已阅读,http://developer.android.com/guide/components/tasks-and-back-stack.html我已经查阅了FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET 的文档,但我仍然不明白为什么 Google 的一名员工决定将其包含在他们关于共享的博客文章中。

http://android-developers.blogspot.com/2012/02/share-with-intents.html

这是他们的代码 fragment :

Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

// Add data to the intent, the receiving app will decide what to do with it.
intent.putExtra(Intent.EXTRA_SUBJECT, “Some Subject Line”);
intent.putExtra(Intent.EXTRA_TEXT, “Body of the message, woot!”);

文档说:

If set, this marks a point in the task's activity stack that should be cleared when the task is reset...

我对这个标志仍然很不确定。我不确定我能想到将它包含在我的 share() 方法中的原因,但如果 Google 在博客文章中使用它,那么我确信他们知道它发挥作用的场景。提前致谢。

最佳答案

文章在第一个代码示例中对其进行了解释:

This flag clears the called app from the activity stack, so users arrive in the expected place next time this application is restarted.

如果您省略标志,当返回到您的应用程序时(从主屏幕、最近等),您会看到共享目标(消息/邮件/IM 应用程序)的 Activity你的。尝试一下,您会发现不同之处。

关于android - 共享时 "FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET"的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21231807/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com