I have two button and it will play a sound to notify about right choice, or wrong one. This is how I do it:
MediaPlayer playError = MediaPlayer.create(QuizA
I'm afraid all answers here are wrong. I encountered this issue, albeit more than a year later, but after some research found the answer. It's in two parts.
- Best to start the mediaplayer AFTER the declaration of the onCompleteListener. This insures that the mediaplayer has a full list of instructions declared before it even start playing.
- Use a statically declared object called an AtomicBoolean. This insures that there is only one boolean parameter, and that the process is locked until it finishes the process. This is the only way to insure a process is thread safe.
Hope you found this useful (all future programmers that encounter this problem) ;-)