Android service startId parameter
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.
精彩评论