StartId parameter for Android service

So, I understand the service life cycle and all that. But am I confused by what for the startId parameter?

 public int onStartCommand (Intent intent, int flags, int startId) 

I understand that it is used together with stopSelf(int) , but I don’t see what kind of point it is or where startId is created. What use case would stopSelf (int) use?

+6
android service lifecycle
source share
1 answer

In which case the use of stopSelf (int) will fall under?

Step # 1: Call startService()

Step # 2: call startService() again

Step # 3: stopSelf()

At this point, we want the service to not be stopped, because the work represented by the second call to startService() is still not working. We want the startService() and stopSelf() calls to match.

+4
source share

All Articles