So I understand the service lifecycle and all that. But I'm confused what the startId
parameter is for?
public int onStartCommand (Intent intent, int flags, int startId)
I get that it's used in conjunction with stopSelf(int)
, but I don't see what the point is or where the startId is being generated. What use case would using stopSelf(int) fall under?
What use case would using stopSelf(int) fall under?
Step #1: Call startService()
Step #2: Call startService()
again
Step #3: Call stopSelf()
At this point, we want the service to not be stopped, since there is still work outstanding, represented by the second startService()
call. We want the startService()
and stopSelf()
calls to match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With