gpt4 book ai didi

android - 关于 Intent 的后期运行时绑定(bind)

转载 作者:行者123 更新时间:2023-11-29 15:23:20 25 4
gpt4 key购买 nike

我尝试浏览开发者论坛以了解 Intent 。我对它了解不多。特别是这些行。

“Android 中的 Activity 是通过称为 Intent 的消息激活的。 Intent 消息传递是一种用于在相同或不同应用程序中的组件之间进行后期运行时绑定(bind)的工具。 Intent 本身是一个 Intent 对象,是一种被动数据结构,包含对要执行的操作的抽象描述。”

我有几个问题。

(a)Why is the intent messaging facility considered as a late run-time binding between components?

(b)Why is the word “passive” used for the intent data structure?

(c) Can anybody give me with an example what this abstract description of an operation to be performed means ?

最佳答案

Why is the intent messaging facility considered as a late run-time binding between components?

因为它不是组件之间的编译时绑定(bind)(例如,使用 Java 构造函数)。

Why is the word “passive” used for the intent data structure?

因为 Intents 是消息,它们本身不会工作,而是指示其他事情要做的工作。

Can anybody give me with an example what this abstract description of an operation to be performed means ?

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://commonsware.com")));

这里,Intent 是一个抽象描述:我们想要“查看”由以 http:// 开头的 URI 标识的内容。在 Android 上,任何数量的 Activity 都可以响应此 Intent,包括 Web 浏览器和秃头家伙支持其网站的专用应用程序。根据设备的不同,零个、一个或多个 Activity 可以匹配此 Intent 结构,Android 可以处理所有这些场景。

关于android - 关于 Intent 的后期运行时绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15879560/

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