Unfortunately this is a problem with some smartphones from what I've seen and experienced. It usually occurs when listening to music via the headphone jack (whether using headphones or a stereo cable). During music play or even after, unplugging the cable from the jack leaves the phone in this state (speakerphone only mode). As a result I've developed the habit of checking my phone everytime I unplug my headphones. To do this I simply click the volume up / down button and listen for the beep. If no beep, I know it's stuck in speakerphone only mode. So all I do is launch the music player and an mp3, then plug in my headphones (or aux cable) in and out of the jack which usually clears it. I've had one instance where it didn't clear and I had to reboot the phone but that was only once and 8 out of 10 times I don't have the problem to begin with.