0
votes

I'm trying to understand how the service will behave when onStartCommand will return START_REDELIVER_INTENT.

If we assume that from an activity we call the service several times. In onStartCommand we receive the intent and a startID. For example the following have been received:

onStartCommand - intent A, startID = 1

onStartCommand - intent B, startID = 2

onStartCommand - intent C, startID = 3

onStartCommand - intent D, startID = 4

onStartCommand - intent E, startID = 5

1) If I call the stopself(id=3) and the service is killed, will intents with startID 1, 2, 4 and 5 redelivered? or only the intents with id higher that the one given in the stopself are redelivered, i.e. 4 and 5?

2) If I call the stopself() does it mean that intents that have been scheduled for redelivery are cancelled?

Any feedback is appreciated,

Lupe.

1

1 Answers

0
votes

Few statements from Android documentation

"Stop the service if the most recent time it was started was startId"

"allows you to safely avoid stopping if there is a start request from a client that you haven't yet seen in onStart(Intent, int)."

So in your example, calling stopSelf(3) will not stop your service. Hope this answers your question.