有什么意图过滤器是什么呢? [英] What are Intent Filters exactly?

查看:242
本文介绍了有什么意图过滤器是什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过许多关于意图过滤器的文章,我真的不明白,究竟是什么呢?

I've read lots of articles about intent filters and I really can't understand exactly what they do?

所以请,如果任何人都可以向我解释有一个明显的例子是什么意图的作用完全过滤器?

so please if anybody can explain to me with a clear example what is the role of intent filters exactly ?

感谢

推荐答案

我认为这是有据可查的这里。总之,(如)你传递一个意图Context.startActivity,或Context.startService,或Context.sendBroadcast播放它,等等,什么活动或服务(或者,什么套广播接收器)的意图传递给?

I think it's well documented here. Summarizing, when (e.g.) you pass an intent to Context.startActivity, or Context.startService, or broadcast it with Context.sendBroadcast, etc, what activity or service (or, what set of broadcast receivers) is the intent delivered to?

答:如果目的是明确的,也就是说,它具有组件名称字段设置,那么它交付给它指定了目标组件 - 这通常发生在通信应用程序中的

Answer: if the intent is "explicit", i.e., it has the component name field set, then it's delivered to the target component it designates -- this typically happens in communication within an application.

否则(隐性的意图,是典型的在的应用程序进行通信的),机器人必须确定自己的最佳活动或服务(或一组接收器)。如何Android的做到这一点?这就是过滤进来,我引用:

Otherwise ("implicit" intent, as is typical for communication between applications), Android must determine the best activity or service (or set of receivers) on its own. How does Android do that? That's where filters come in, and I quote:

它通过比较所述内容   意图对象为意向   过滤器,结构关联   部件可以潜在   收到意图。过滤器做广告   一个组件的功能和   划定的意图,它可以处理。   他们打开组件到   接收隐含的可能性   播发类型的意图。如果一个   组件没有任何意图   过滤器,它只能接收显   意图。带过滤器的组件可以   同时接收显性和隐性   意图。

It does so by comparing the contents of the Intent object to intent filters, structures associated with components that can potentially receive intents. Filters advertise the capabilities of a component and delimit the intents it can handle. They open the component to the possibility of receiving implicit intents of the advertised type. If a component does not have any intent filters, it can receive only explicit intents. A component with filters can receive both explicit and implicit intents.

有问题的网页继续与许多细节,并在结束时,一个完整的,简单的例子,我认为这将是多余的将其复制并粘贴到这里。

The web page in question continues with many details and, at the end, a complete, simple example, and I think it would be redundant to copy and paste them here.

这篇关于有什么意图过滤器是什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆