Detect lack of earpiece (speakerphone only) on an Android device
<p>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.</p>

<p>Ideally, I'd like to use some kind of <code>isEarpiecePresent()</code> 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.</p>

<p>I attempted to work around the issue by calling <code>AudioManager.setSpeakerphoneOn(false)</code>, then checking <code>AudioManager.isSpeakerphoneOn()</code>, hoping that it would still return true and I could key off of that.  The system returned <code>false</code>, even though audio is still routing through the speaker.</p>

<p>I'm currently thinking of checking for telephony capability, even though that doesn't exactly fit.  Any other ideas?</p>
