I've got an app which displays a speakerphone toggle button when used on a phone. The toggle switches audio routing between the phone's earpiece and the speakerphone. However, when the app is run on a tablet (or any device which lacks an earpiece), I'd like to remove the toggle, since all audio is routed through the speakerphone.
Ideally, I'd like to use some kind of isEarpiecePresent()
call, or maybe check a flag on some configuration object to find this information, but I can't find anything of the sort in the API.
I attempted to work around the issue by calling AudioManager.setSpeakerphoneOn(false)
, then checking AudioManager.isSpeakerphoneOn()
, hoping that it would still return true and I could key off of that. The system returned false
, even though audio is still routing through the speaker.
I'm currently thinking of checking for telephony capability, even though that doesn't exactly fit. Any other ideas?