如果我多次调用 context.startForegroundService(startServiceIntent),我会多次调用具有新服务意图的 onCreate() 还是第一次调用 onCreate 以获得新的服务意图,然后多次调用 onStartCommand()/onHandleIntent()次?
这取决于服务是否正在运行。如果该服务尚未运行,startForegroundService()将触发调用onCreate()。
因此,例如:
startForegroundService()onCreate()它onStartCommand()它(这可能会触发对其他事物的调用,例如onHandleIntent()of IntentService)startForegroundService()再打电话onCreate()调用onStartCommand()它(这可能会触发对其他事物的调用,例如onHandleIntent()of IntentService)stopService()或stopSelf()(或onHandleIntent()返回,如果您仍在使用IntentService)startForegroundService()再次打电话,因为你真的很喜欢那个方法onCreate()它onStartCommand()它(这可能会触发对其他事物的调用,例如onHandleIntent()of IntentService)| 归档时间: |
|
| 查看次数: |
585 次 |
| 最近记录: |