I start here, I have a simple question.
In Android, would it be better to check something at regular intervals?
Please carry me, I will try to explain what I can -
For example, my sound application is very simple, basic action and service. The main action has a user interface with two buttons, start and stop the sound. I press the "Start" button and the sound service starts. Likewise, when I click Stop, the service stops and the sound ends. If isLooping() hardcoded to the truth, there is no problem because the sound never ends unless I find a stop button that stops the audio service and also resets the state of the buttons.
This is a problem now, because I set isLooping() to false so that the sound does not loop. Thus, the sound will stop playing, but the service is still running.
I want to be able to detect when the sound stops, so I can set the states of the user interface buttons. So I need something that always checks if the sound is playing (i.e. Check player.isPlaying() so that I can complete the service and set the on / off state of the buttons.
I understood the binding to the service, so I can access the MediaPlayer controls through my main activity, so I know the code to check if it plays, but WHERE do I put this code all the time so that it checks all the time?
Do I make sense? I know that this is probably very simple. Thanks for any help.
source share