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 AutoCompleteTextView 的 setAdapter方法的坑! 设置进去
  5. Android学习第六周_SQLite和ContentProvider
  6. Android(安卓)之 Fragment的动态加载
  7. Android(安卓)程序获取、设置铃声、音量、静音、扬声器
  8. Android(安卓)RelativeLayout(7.1) 源码解析
  9. android.os.DeadObjectException

随机推荐

  1. SystemServer(一):恢复出厂设置后wifi、数
  2. Spinner的功能和用法-通过XML生成
  3. ContentProvider的工作过程
  4. Android(安卓)安卓MVC架构
  5. Android(安卓)指纹识别注意升级问题
  6. Android中的System UI Visibility
  7. 记录的Android开发过程中遇到的问题。
  8. Android(安卓)四大组件之 Service (一)
  9. Mac OSX 下 手动更新 Android(安卓)Studi
  10. Android模拟器镜像介绍