Acitivity
1 Intent
2 responseCode requestCode
3 Activity 生命周期
-----------------------------------------------
Service
注意:不需要用户界面运行程序
1) startService(intent);
|
onCreate()
|
onStartCommand() === onStart();
|
Service
|
stopService(intent)
|
onDestroy();
2) bindService(intent,null,BIND_AUTO_CREATE);
|
onCreate
|
onBind
|
Service
|
unBindService(null);
|
onUnBind();
|
onDestroy();
问题
0
a) MyService extends Service{
onCreate(){
//书写 网络连接
}
onStartCommand(){
//书写 网络连接
}
onDestry(){
}
}
b) AndroidMenifest.xml
<service android:name = ""/>
1 Service启动 --> acitivity
intent
button --- startService bindService
button --- stopServiec unBindService
-------------------------------------------
如果启动Service后在其他组件中还要对
Service对象进行处理
那么使用BindService这种方式启动Service
My类 implements IBind
Bind implements IBind
My类 extends Binder
-----------------------------------------------
BroadcastReceiver
广播接收者
1 广播电台 发送广播 频率
Intent i = new Intent();
i.setAction();
sendBoradcast(i)
2 广播接收者 收音机
1) extends BoradcastReceiver{
onReceive{
}
}
2) 配置文件进行配置
<receiver>
<intent-filter>
<action>
</
intent
Activity --- Activity
-------------------------------------------------
手机 ----- 别人的手机
android系统接收到有短息这个事时
android发送一个短息广播
短信软件 广播的接收者
解耦合的思想
强耦合
手机 ------ 我手机短信
android ---- 短息软件处理
弱耦合
权限:
org.android.permission.RECEIVED_SMS
Action
android.provider.Telephony.SMS_RECEVIED