首页 > 其他 > 详细

Service 中onStartCommand方法参数的含义

时间:2015-07-11 13:42:59      阅读:1841      评论:0      收藏:0      [点我收藏+]

在Service中onStartCommand(Intent intent, int flags, int startId)这三个参数的含义分别是,intent就是startService(Intent intent)中的intent;flags代表flags表示启动服务的方式:  

Additional data about this start request. Currently either 0, START_FLAG_REDELIVERY, or START_FLAG_RETRY.  

  

START_FLAG_REDELIVERY: 如果你实现onStartCommand()来安排异步工作或者在另一个线程中工作, 那么你可能需要使用START_FLAG_REDELIVERY来 让系统重新发送一个intent。这样如果你的服务在处理它的时候被Kill掉, Intent不会丢失.  

START_FLAG_RETRY:表示服务之前被设为START_STICKY,则会被传入这个标记。 startId的值为对这个service请求的activity或者其他实体的编号,唯一。


Service 中onStartCommand方法参数的含义

原文:http://my.oschina.net/u/1463920/blog/477275

(2)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!