Android Service Onstartcommand Method Param Uses
with updated SDK version now Service class has override method int onStartCommand (Intent intent, int flags, int startId) & it has replaced following which was introduce wit
Solution 1:
Firstly, documentation explicitly says not to call these methods yourself, therefore you would manipulate them elsewhere.
flags
int
: Additional data about this start request. Value is either 0 or combination ofSTART_FLAG_REDELIVERY
orSTART_FLAG_RETRY
.
Those constant flags are described in the same page
It's not clear to me where that input comes from, but you combine that integer with bitwise OR, for example
return flags | START_REDELIVER_INTENT;
And
startId
int
: A unique integer representing this specific request to start. Use withstopSelfResult(int)
.
So, the id is used for logging and getting a handle to the service to stop it
Post a Comment for "Android Service Onstartcommand Method Param Uses"