Service
1.两种启动模式
1.启动模式
startService()
在后台一直运行
不随组件的消亡而消亡
执行单个操作
不能返回结果
2.绑定模式
bindeService()
随组件的消亡而解除绑定
一个服务可以对应多个组件
-
两种模式可以同时运行,生命周期个不行同(大同小异)
-
生命周期
绑定模式,多了一个接触绑定的操作
-
启动服务
1.启动模式
Intent intent = new Intent(activity.this,srvice.calss);
startService(intent);
2.绑定模式
bindService();
unbindService()
- 前台服务
1.startForeground(int,notification)
stopForeground(true)