2

I have 2 calls to startService made on the same thread, but apparently these calls are received out of order in my IntentService.

Our client says that the feature works on some devices and no on others, so I'm guessing this out of order could be the case.

I know that IntentService has a FIFO way to execute the Intents. So, once the intent arrives, the order is guaranteed. My question is that could be possible that one startService was delayed and the other goes first. Does anyone have any idea how startService works internally?

The code goes more or less like this

(... some logic...)

callService(param1)

(... more logic...)

callService(param2)
Paulo Morandi
  • 147
  • 1
  • 10
  • why is the order of execution important? – Tim Jan 10 '19 at 12:40
  • What if (... some logic...) gets finished after {more logic} ? – Rohit Singh Jan 10 '19 at 12:47
  • It's a business requirement, nothing particularly special. I'm just searching for what caused the problem. I can easily change this. Just curious to understand if this is possible. I'm not 100% convinced that this could happens, so I decided to ask here if anyone knows about how startService works. – Paulo Morandi Jan 10 '19 at 12:47
  • @RohitSingh it's not done in parallel. They are sequential. – Paulo Morandi Jan 10 '19 at 12:48
  • 3
    *could be possible that one startService was delayed and the other goes first.* - no, startService is synchronous and returns immediately, the work is sent to the service under the hood. Nowhere is written that sequential calls to startService are guaranteed to result in the same sequence of delivered intents – Tim Jan 10 '19 at 12:56
  • @TimCastelijns I see, so internally they could result in different order.. makes sense, since they don't ever say anything about order of deliver.. could you post this comment as answer please? Thanks for the help. – Paulo Morandi Jan 10 '19 at 13:00
  • I just stated some info, I don't think it completely answers your question. If you feel you have enough info now, you can also write up an answer yourself – Tim Jan 10 '19 at 13:08

0 Answers0