根据此处的 Android 文档:
onStartCommand()
仅在用户明确启动服务时触发
当系统启动使用START_STICKY
启动的服务时调用哪个方法?
最佳答案
将重新创建服务
。
onCreate()
和 onStartCommand()
都会被调用。
来自documentation :
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; 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.
关于Android Service System使用start Sticky重启服务时调用哪个方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37992838/