一、在MainAcitivity界面启动Service  :

public class MyService extends Service
intent = new Intent(MainActivity.this,MyService.class);
startService(intent);

service 启动,先执行 MyService() 这个构造函数, 再执行 onCreate() ,然后执行 onStartCommand() 函数。

停止服务:
stopService(intent);  onDestroy()

绑定服务:
bindService(intent,this, Context.BIND_AUTO_CREATE);   MyService() ; onCreate();  IBinder onBind(Intent intent);  onServiceConnected() ; 

解除绑定: 
unbindService(this);  onDestroy()

最新文章

  1. hdu 2054
  2. Red Gate系列之三 SQL Server 开发利器 SQL Prompt 5.3.4.1 Edition T-SQL智能感知分析器 完全破解+使用教程
  3. 基于MATLAB的中值滤波均值滤波以及高斯滤波的实现
  4. Jace 上新建 Station 配置 笔记
  5. [ISSUE] [Centos] Centos Start Nginx Show: Failed to start nginx.service:unit not found
  6. SQL Server如何查找表名或列名中包含空格的表和列
  7. 提高工作效率-window热键
  8. proxy.conf编写
  9. Bootstrap 固定底部导航栏菜单
  10. Python——lambda函数
  11. MySQL Workbench在archlinux中出现 Could not store password: The name org.freedesktop.secrets was not provided by any .service files的错误
  12. URL基本结构
  13. R语言中知识点总结(一)
  14. sqoop快速入门
  15. hdu Encoding
  16. spring mvc实现接口参数统一更改
  17. vue-awesome-swiper
  18. [PHP] ubuntu16.04下 Phpstorm发布项目到apache
  19. Spring与web MVC的整合——Spring的应用上下文管理
  20. BZOJ 3876 【AHOI2014】 支线剧情

热门文章

  1. SDWebImage源码解读之SDWebImageCache(下)
  2. vscode 1.5安装体验
  3. 编写高质量代码:改善Java程序的151个建议(第8章:异常___建议114~117)
  4. JDBC简介
  5. css中line-height行高的深入学习
  6. ES6(块级作用域)
  7. 微信小程序二维码推广统计
  8. 简单的转盘抽奖——CSS动画优化
  9. ABP框架 - 模块系统
  10. 后HTML5时代