Good night.
So, how does service Starts work.
In case you send a startService()
, it will be started with the return setting of the onStartCommand()
however, if you start via BindService()
it will be a service attached to that class, when it ceases to exist, it will be finalized. so it does not go through a onStartCommand()
I will give an example in which I used, to see if understanding is better.
I created a Mediaplayer, which should be running even with the dead application, similar to Googleplay Musica.
When selecting a song, I would give a startService()
on my player service and right 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 player screen, the player would be an extra application, if the person opened the player, it would give bind, otherwise, would not have any connection with the player, soon, the service would be alive only by startService()