Android服务的startId参数

Fal*_*rri 6 service lifecycle android

所以我了解服务生命周期以及所有这些.但我很困惑startId参数是什么?

public int onStartCommand (Intent intent, int flags, int startId)
Run Code Online (Sandbox Code Playgroud)

我得到它与它一起使用stopSelf(int),但我看不出有什么意义或者生成startId的地方.什么用例会使用stopSelf(int)?

Com*_*are 5

什么用例会使用stopSelf(int)?

第一步:打电话 startService()

第二步:startService()再次打电话

第3步:打电话 stopSelf()

此时,我们希望服务不会停止,因为仍有未完成的工作,由第二个startService()调用表示.我们希望startService()stopSelf()调用匹配.