Service 中onStartCommand方法参数的含义

在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.  this

  

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

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

相关文章
相关标签/搜索