【发布时间】:2014-01-20 10:42:20
【问题描述】:
我已阅读 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
这是他们的代码 sn-p:
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 documentation 中解释了一个用例。
-
这个标志现在被弃用了,因为它和
Intent.FLAG_ACTIVITY_NEW_DOCUMENT做同样的事情 -
@EGHDK 请将此问题标记为已回答,以帮助其他有相同问题的人。
标签: android android-intent back-stack android-sharing