I have to read a single digital input signal (a trivial open/closed-circuit push button) and use this signal in an Android application on a smartphone.

Of course, I could connect a tiny Arduino-like board to the USB port of the smartphone, use the digital input pins of this board to read the electrical signal and pass a message to the Android app but this task is so simple that I would like to avoid the use of any addictional board.

So, I wonder if it would be possible to (ab)use a regular headset wire for this task.

I would like to connect a regular 3.5mm headset to the smartphone, cut away the actual speakers and microphone, connect two of the resulting free wires to my push button and read the open/closed-status change of the switch from my app.

As long as I can see, Android has a ACTION_HEADSET_PLUG intent and a AudioManager.isWiredHeadsetOn() function so this is probably possible.

Does anybody have any idea about the correct wiring I should use? In particular, should I insert a resistor/capacitor to protect the inner circuitry of the audio board?

Any suggestion about the software side?

Please note that I'm only interested in reading the change of the switch status from open to closed or viceversa. I do not need to know the current status of the switch.

PS: No, I'm not willing to destroy the smartphone and connect the external push button to the existing keyboard.

  • \$\begingroup\$ The android klick button does this. EBay for a few bucks. Same as a headset with a play/stop button \$\endgroup\$
    – Passerby
    Jul 6, 2015 at 20:36

4 Answers 4


If you have the kind of headset with built in volume controls, you could wire your switch to the mute or volume buttons and detect that being pressed from your app. In fact...you could probably just use the existing button. That would be the easiest and most reliable to detect.

  • \$\begingroup\$ Thanks Grant, this seems to be the easiest and most reasonable way to get what I need. See my edit for some more information. \$\endgroup\$ Jul 6, 2015 at 19:34
  • \$\begingroup\$ @alexbottoni sounds like you are well on your way, and its probably easier than you thought :) Nice thing about this method is android handles all the polling and detection for you, and your app just registers the events it wants to know about. \$\endgroup\$
    – Grant
    Jul 6, 2015 at 20:19

You cannot make use of the headphone switch built into the phone, since this is a mechanical switch that opens or closes depending on whether a jack is plugged in. There is no external access to the wires for this switch.

I would use a 555 to create a tone, say 1 kHz. Connect the output to the MIC input of the headset jack. Then use the switch to turn the tone on or off. There should be a way to determine if there is audio or no audio going into the MIC input. Note this would require you to poll the input on a regular basis though.


I'm answering myself to add some more information.

Android headset control system can read up to four different buttons on the standard microphone line. They are normally used for answer/refuse, play/pause, scan and other commands.

Each button is assigned a different resistor and is recognised thanks to the resulting resistance on the line when the circuit is closed. Mic is assigned the higher resistance (5000 ohms), the play/pause button is assigned the lowest one (0 hms) and the other buttons are in the middle.

Android platform software supplies a MEDIA_BUTTON intent to intercept and handle these "events". You just have to create a single broadcast receiver and an a handling function for each event.

Using this HW/SW stuff it is possible to read up to four digital (1/0, open/closed) input lines and even an analogic one (the Mic, that can be used a an oscilloscope).

Of course, you have to use a standard headset 3,5mm jack to create your own "digitizing board".

Here some reference and some useful link.

Hardware side Android specifications supply all the required information here: Wired audio headset specification (v1.1)

(I do not know if all existing devices comply with these specs.)

Software side

There are a few guides/tutorials that explains how to detect and handle events coming form the headset buttons (both wired and Bluetooth):

Allowing applications to play nice(r) with each other: Handling remote control buttons

Add Headset button support to your Android application

And there is a complete sample application on Github:


Here is a commercial app that uses all of the above to implement a better control for the headset buttons:

Headset Button Controller (Trial)

Funny stuff, really.


Current answers about the headset buttons aside, a simple way would be blue tooth button as well. No wires, and easily supported by any app you create. They are very common at the moment, part of the selfie stick craze.

Another wireless version is nfc buttons. Same concept.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.