How to Detect Headset Capabilities
Asked Answered
N

1

7

I know how to detect whether a headset is plugged in but some headsets (e.g Samsung EHS60ANNBE) come with the PAUSE/PLAY (a.k.a KeyEvent.KEYCODE_HEADSETHOOK) button only, without the PREV/NEXT...

I would like to be able to detect whether the headset currently plugged into the Android device has PREV/NEXT (a.k.a KeyEvent.KEYCODE_MEDIA_PREVIOUS/KeyEvent.KEYCODE_MEDIA_NEXT) or not.

Is this possible?

Needy answered 27/3, 2013 at 18:1 Comment(0)
C
1

Are you using a BroadcastReceiver? I'm guessing you are.

from Android Dev:

public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
        //receive the key press event
        KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
        //check the keypress
        if (KeyEvent.**** == event.getKeyCode()) {
            // Handle key press.
        }
    }
  }
}

** a link with various keypress codes

Copalite answered 4/1, 2014 at 17:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.