Issues with ACTION_HEADSET_PLUG broadcast in Android
- by Denis M
I've tried these phones: Moto Backflip 1.5, Nexus One 2.1
Basically I register BroadcastReceiver to get ACTION_HEADSET_PLUG broadcast and look on 3 extras that come in intent:
state
name
microphone
Here is the description from API:
* state - 0 for unplugged, 1 for plugged.
* name - Headset type, human readable string
* microphone - 1 if headset has a microphone, 0 otherwise
Issue #1: Broadcast comes when activity is started (not expected), when screen rotation happens (not expected) and when headset/headphones plugged/unplugged (expected).
Issue #2: Backflip phone sends null for state + microphone, 'No Device' as name when headset/headphones unplugged, and sends null for state + microphone, 'Stereo HeadSet'/'Stereo HeadPhones' as name when headset/headphones plugged.
Nexus even worse, it always sends null for state + microphone, 'Headset' as name when headset/headphones plugged or unplugged.
Question: How it can be explained that API is broken so much on both 1.5 and 2.1 versions and different devices, manufactures?