Intent七大属性之总结

来源:互联网 发布:word 2011 mac 破解版 编辑:程序博客网 时间:2024/04/28 00:05


参考《疯狂android讲义》第5章


1、Intent 用于封装程序的”调用意图“,不管想启动一个Acitivity、Service还是BroadcastReceiver,Android均使用统一的Intent对象来封装这种”启动意图“。很明显使用Intent提供了一致的编程模型。


2、Intent还有一个好处,如果应用程序只是想启动具有某种特征的组件,并不想和某个具体的组件耦合,则可以通过在intent-filter中配置相应的属性进行处理,与stucts2中的MVC框架思路类似。


3、Intent对象大致包括7大属性:ComponentName  Action  Category  Data  Type  Extra  Flag。


4、7大属性中,前面5个均用于指定本intent用于启动哪个组件,ComponentName直接指定组件的名称,后4个指定类型,只要符合此类型条件的组件均可响应此Intnet。前者称为显式Intnet,后者称为隐式intent。前者一般用于启动自身程序的其它组件,后者一用于启动其它程序的组件(包括系统组件)。

  • Explicit intents designate the target component by its name (the component name field, mentioned earlier, has a value set). Since component names would generally not be known to developers of other applications, explicit intents are typically used for application-internal messages — such as an activity startinga subordinate service or launching a sister activity.
  • Implicit intents do not name a target (the field for the component name is blank). Implicit intents are often used to activate componentsin other applications.



说见Intent七大属性之一~~~七

原创粉丝点击