Android Service 中 onStartCommand()函数返回值含义

本文详细介绍了Android Service中onStartCommand()函数的返回值含义,包括START_STICKY、START_STICKY_COMPATIBILITY、START_NOT_STICKY和START_REDELIVER_INTENT。这些返回值决定了Service在被杀死后的行为,例如是否重新启动,以及如何处理未完成的Intent。
摘要由CSDN通过智能技术生成

onStartCommand()是由Android系统调用的,本质上也是调用了onStart()方法。

onStartCommand()返回值有几种:

1)START_STICKY

英文解释:

Constant to return from onStartCommand: if this service's process is killed while it is started (after returning from onStartCommand), 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 after creating the new service instance; 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 c

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值