Good evening.
So how does service starts?
If you send a startService()
, it will start with the onStartCommand()
setting
However, if you start via BindService()
it will be a service attached to that class, when it ceases to exist, it will be terminated. so it does not pass through a onStartCommand()
I will give an example in which I used it, to see if it gets better understanding.
I created a MediaPlayer, which should be running even with the dead application, similar to GooglePlay Music.
When selecting a song, I gave startService()
to my player service and soon after a bindService()
to be able to update the service through the application, since I would need to be able to play, pause, etc ... however not always I would be on the screen of the player, the player would be an extra of the application, if the person opened the player, it would bind, otherwise it would not have any connection with the player, so the service would be alive only by startService()
/ p>