Is there any other reason that the Intent that is passed to onStartCommand(Intent, int, int)
would be NULL besides the system restarting the service via a flag such as START_STICKY
?
Also, when the service is restarted by the system the Intent.getAction()
method returns NULL... sometimes. Intent is not NULL just getAction()
I asked here too but haven't received an answer just yet.
UPDATE: After chatting with Mark Murphy, he suggested that I return START_REDELIVER_INTENT
in the onStartCommand()
callback in my service instead of START_STICKY
so that the entire intent is sent following a restart.
I didn't do this initially because I was concerned that if the service was attempting to do something, then in the middle of that something the service was restarted... will it recognize that it started doing that something? I guess that is logic I will need to be responsible for :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…