Android服务使用start Sticky重新启动系统时调用哪种方法

时间:2016-06-23 13:18:21

标签: android android-service

根据此处的Android文档:

https://developer.android.com/reference/android/app/Service.html#onStartCommand(android.content.Intent, int, int)

仅当用户明确启动服务时才会触发

onStartCommand()

系统启动使用START_STICKY启动的服务时调用哪种方法?

1 个答案:

答案 0 :(得分:1)

将重新创建Service

将调用onCreate()onStartCommand()

来自documentation

  

稍后系统将尝试重新创建服务。因为它在   启动状态,它将保证调用onStartCommand(Intent,   int,int)创建新服务实例后;如果没有   任何挂起的启动命令将被传递给服务,它将是   使用null intent对象调用,因此您必须注意检查   此