gpt4 book ai didi

Android Service System使用start Sticky重启服务时调用哪个方法

转载 作者:行者123 更新时间:2023-11-29 01:19:02 26 4
gpt4 key购买 nike

根据此处的 Android 文档:

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

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com