gpt4 book ai didi

android - list 标签

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

在 Android 中, 的用途是什么?来自 documentation ,它似乎只是现有 < activity > 的另一个名称,其 Intent 过滤器会覆盖目标 Activity 的过滤器(到目前为止我的理解)。

它的实际用途是什么?

调用者能否同时向目标和别名发送 Intent ?

最佳答案

it seems that it is just another name for an existing < activity > with intent filters that override the target activity's filter (my understanding so far).

我将其定义为“提供额外的过滤器”,而不是覆盖。

What is its practical use ?

您可以禁用组件,例如 <activity-alias> .您不能禁用 <intent-filter>元素(尽管那会非常方便)。

因此,如果您有一项 Activity 希望始终可用,但只有 一些 时间提供特定过滤器(或多个过滤器),<activity-alias>是给你的。

这方面的现代示例来自新的存储访问框架。过去,要使文档对第三方应用程序可用,您需要实现 ACTION_GET_CONTENT。 Activity ,带有 <intent-filter>广告相关的 MIME 类型(可能还有您的提供商的 ContentProvider 路径)。但是,如果您在 Android 4.4+ 上采用存储访问框架,您不希望拥有 ACTION_GET_CONTENT可用 Activity ——最终效果是您的所有内容都会出现两次。因此,在 Android 4.4+ 设备上,您需要禁用整个 Activity (如果您不需要它做任何其他事情),或者移动 ACTION_GET_CONTENT <intent-filter><activity-alias> ,因此您可以单独禁用它。这在 the documentation 中有更详细的介绍。 .

TL;DR:我怀疑是否有许多开发人员使用 <activity-alias> ,尽管它有它的用例(例如,在对您的问题的评论中引用的启动器)。

Can a caller send an intent both to the target and the alias ?

嗯,如果您的意思是“我可以使用 startActivity() 来启动 Activity 或别名吗?”,那么可以。

关于android - <activity-alias> list 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24112043/

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