安卓学习47

今天学习了安卓的一些知识其中主要的是:

Service 服务 后台运行没有界面 执行耗时的操作 单例 但是要开线程
1 init 初始化 1.1 MyService extends Service 1.2 注册 
2 启动方式:2.1 startServie() stopService() onCreate() onStart() onDestory()
2.2 bindService() unbindService() onCreate() onBind() onUnbind() onDestory()
3 bindService ServiceConnection onBind() -->IBinder 调用服务里面的方法
3.1 本地 1 定义一个接口 2 MyService private class MyBinder extends Binder implements 接口 
3.2 其他应用程序的
aidl 解决跨进程访问的问题 需要带包复制
1 定义一个接口 
2 把.java修改为.aidl 去掉public 
3 MyService private class MyBinder extends Stub
4 Activity Stub.asInterface(IBinder);

aidl里面可能要传递对象
1 MyBean implments Parcalable 
2 编写aidl描述文件
package com.itcast.service.domain;
parcelable Student;

ContentProvdier
BroadcastReceiver

原文地址:https://www.cnblogs.com/092e/p/14916684.html