Service 常量

public static final int START_CONTINUATION继续_MASK化装

Added in API level 5 


Bits returned by onStartCommand(Intent, int, int) describing how to continue the service if it is killed描述如何继续服务如果是死亡. May be START_STICKY, START_NOT_STICKY, START_REDELIVER_INTENT, or START_STICKY_COMPATIBILITY. 
Constant Value: 15 (0x0000000f) 

public static final int START_FLAG_REDELIVERY重新发还

Added in API level 5 


This flag is set in onStartCommand(Intent, int, int) if the Intent is a re-delivery of a previously delivered intent如果目的是re-delivery之前交付的意图, because the service had previously returned因为服务之前返回START_REDELIVER_INTENT but had been killed before calling但是在调用之前被杀stopSelf(int) for that Intent的意图. 
Constant Value: 1 (0x00000001) 

public static final int START_FLAG_RETRY重试

Added in API level 5 


This flag is set in onStartCommand(Intent, int, int) if the Intent is a retry because the original attempt never got to or returned from如果目的是重试,因为最初的尝试从来没有回来onStartCommand(Intent, int, int). 
Constant Value: 2 (0x00000002) 

public static final int START_NOT_STICKY粘的

Added in API level 5 
Constant to return from onStartCommand(Intent, int, int): if this service's process is killed while it is started (after returning from onStartCommand(Intent, int, int)) 如果这个服务的过程开始时被杀, and there are no new start intents to deliver to it没有新的开始的意图, then take the service out of the started state and don't recreate until a future explicit call to Context.startService(Intent) 然后把服务的开始状态不重现,直到未来的显式的调用. The service will not receive a服务不接受onStartCommand(Intent, int, int) call with a null Intent because it will not be re-started if there are no pending Intents to deliver一个空的意图,因为它不会构成威胁如果没有悬而未决的意图. 
This mode makes sense for things that want to do some work as a result of being started, but can be stopped when under memory pressure and will explicit start themselves again later to do more work这种模式是有意义的事情,想做一些工作的开始,但可以停止在内存压力下,稍后再将显式开始自己做更多的工作。. An example of such a service would be one that polls for data from a server这种服务的一个例子将是一个民意调查数据从服务器: it could schedule an alarm to poll every N minutes by having the alarm start its service可以安排警报来调查每N分钟警报开始其服务. When its onStartCommand(Intent, int, int) is called from the alarm被称为从闹钟, it schedules a new alarm for N minutes later, and spawns a thread to do its networking安排一个新的N分钟后报警,并产生一个线程网络. If its process is killed while doing that check如果它的进程被杀而这样做检查, the service will not be restarted until the alarm goes off服务将不会被重新启动,直到闹钟响。. 
Constant Value: 2 (0x00000002) 

public static final int START_REDELIVER再投递_INTENT 

Added in API level 5 


Constant to return from onStartCommand(Intent, int, int): if this service's process is killed while it is started (after returning from onStartCommand(Intent, int, int)) 如果这个服务的过程开始时被杀, then it will be scheduled for a restart and the last delivered Intent re-delivered to it again via onStartCommand(Intent, int, int) 然后它将定于重启最后目的re-delivered一遍通过交付. This Intent will remain scheduled for redelivery until the service calls意图仍将安排返还到服务调用stopSelf(int) with the start ID provided to onStartCommand(Intent, int, int) 开始提供的ID. The service will not receive a服务不接受onStartCommand(Intent, int, int) call with a null Intent because it will will only be re-started if it is not finished processing all Intents sent to it与一个空的电话的意图,因为它将只会四散离去如果没有完成处理所有意图发送给它(and any such pending events will be delivered at the point of restart). 
Constant Value: 3 (0x00000003) 

public static final int START_STICKY粘的

Added in API level 5 


Constant to return from onStartCommand(Intent, int, int): if this service's process is killed while it is started (after returning from onStartCommand(Intent, int, int)) 如果这个服务的过程开始时被杀, then leave it in the started state but don't retain this delivered intent. Later the system will try to re-create the service然后把它的开始状态但不保留这个意图。之后,系统会尝试重新创建服务. Because it is in the started state, it will guarantee to call onStartCommand(Intent, int, int) after creating the new service instance因为它处于启动状态,它将保证调用onStartCommand(意图,int,int)在创建新服务实例; if there are not any pending start commands to be delivered to the service, it will be called with a null intent object, so you must take care to check for this如果没有任何等待开始命令交付服务,它将被称为零意图对象,所以你必须小心检查。. 
This mode makes sense for things that will be explicitly started and stopped to run for arbitrary periods of time, such as a service performing background music playback这种模式是有意义的事情,将显式启动和停止运行任意时间的,如一个服务执行背景音乐播放. 
Constant Value: 1 (0x00000001) 

public static final int START_STICKY_COMPATIBILITY 

Added in API level 5 


Constant to return from onStartCommand(Intent, int, int): compatibility version of兼容性的版本 START_STICKY that does not guarantee that这并不保证 onStartCommand(Intent, int, int) will be called again after being killed被杀后将再次调用。. 
Constant Value: 0 (0x00000000) 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值