Null intent redirected to Service onStartCommand ()

In the documentation for Android, the " onStartCommand() " service has the intent indicated as param , which according to the docs:

"The Intent specified in startService(Intent) as specified. It can be null if the service restarts after its process has left and it previously returned anything other than START_STICKY_COMPATIBILITY ."

However, the return value START_REDELIVER_INTENT should return the original intention when the service was restarted.

Can someone explain why Intent can be null even if flag set to START_REDELIVER_INTENT ?

+6
source share
1 answer

Perhaps you get confused START_FLAG_REDELIVERY with START_REDELIVER_INTENT ? Your message says "return value START_FLAG_REDELIVERY ". This constant is not one of the values ​​returned from onStartCommand , it is one of the bit values ​​passed to onStartCommand as the flags parameter. START_FLAG_REDELIVERY and START_STICKY both have the value 1. If you mistakenly received return START_FLAG_REDELIVERY at the end of onStartCommand() , the service will restart in sticky mode with zero intent if there are no pending responses.

+1
source

All Articles