Skip to content Skip to sidebar Skip to footer

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.

flagsint: Additional data about this start request. Value is either 0 or combination of START_FLAG_REDELIVERY or START_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

startIdint: A unique integer representing this specific request to start. Use with stopSelfResult(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"