Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents.

一、Intent

1、Intent属性、解析
Intent是对执行某个操作的一个抽象描述,其描述的内容包括,对执行动作Action的描述、对操作数据的描述、还有4种附加属性的描述。
Action、data、catagory、extra、component、type
当指定了component属性后,就是显式的指定了目标组件,也就是接收端。如果没有明确指定目标组件,那么Android系统会使用 Intent 里的(action,data,category)三个属性来寻找和匹配接收端。

2、IntentFilter
应用程序组件可以使用IntentFilter来向系统说明自己可以响应和处理那些Intent请求。

二、Service
1、Service是运行在后台的程序。启动的方法有两种:
startService()、bindService()

2、Service lifecycle
继承了onCreate(),onStart(),onDestroy()三个方法,当我们第一次启动Service时,先后调用了onCreate(),onStart()这两个方法,当停止Service时,则执行onDestroy()方法。

AIDL... 这个以后在看!

三、BroadcastReceiver
Broadcast Receiver组件就提供了一种把Intent作为一个消息广播出去,由所有对其感兴趣的程序对其作出反应的机制。
实现BroadcastReceiver:
1、继承BroadcastReceiver类
2、重写onReceive方法
3、AndroidManifest.xml中注册此Receiver,监听action

调用sendBroadcast(intent) 广播出去。

四、Content Provider
1、Content Provider提供了程序之间共享数据的方法,一个程序可以使用Content Provider 定义一个URI,
提供统一的操作接口,其他程序可以通过此URI访问指定的数据,进行数据的增、删、改、查。

2、ContentResolver
ContentResolver接口可以访问ContentProvider提供的数据。

3、ContentProvider和ContentResolver当中用到了Uri的形式通常有两种,一种是指定全部数据,另一种是指定某个ID的数据。我们看下面的例子。
content://contacts/people/ 这个Uri指定的就是全部的联系人数据。
content://contacts/people/1 这个Uri指定的是ID为1的联系人的数据。

Content Provider的使用,直接参看SDK自带的NotePad实例。

更多相关文章

  1. “罗永浩抖音首秀”销售数据的可视化大屏是怎么做出来的呢?
  2. Nginx系列教程(三)| 一文带你读懂Nginx的负载均衡
  3. 不吹不黑!GitHub 上帮助人们学习编码的 12 个资源,错过血亏...
  4. Android(安卓)Handler类消息传递机制(三)不同类中使用Handler
  5. Android从服务器端接收json数据并解析的代码
  6. lua学习笔记 2 android调用Lua。Lua脚本中实现添加Button,并为Bu
  7. Android(安卓)容器控件
  8. Mac Android(安卓)Studio处理unable to access android sdk add-
  9. Android(安卓)onCreate方法被调用两次的解决方法

随机推荐

  1. android UI跨线程操作
  2. GridView
  3. 设置透明,模糊,黑暗度
  4. android aosp 下载源代码
  5. android中关于margin的一些注意点
  6. (20120722)(笔记002)android开发环境搭建
  7. Android资料备注
  8. android:padding 与 android:margin的区
  9. [图解]Android下Invalid layout of java.
  10. Android 软键盘遮挡Dialog