开发者

Android service startId parameter

开发者 https://www.devze.com 2023-01-13 20:51 出处:网络
So I understand the service lifecycle and all that. But I\'m confused what the startId parameter is for?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消