Android Question How to read an external mechanical pushbutton through headphone jack

jbellora

Member
Licensed User
Longtime User
Hello,
I need to read an external pushbutton through the headphone jack. I know that headphones have a mechanical switch that short-circuits one of the headphone plug terminals (rings or tip) to electrical ground.
But I did not find how to read this. Better if it raises an event.
Any help will be welcomed!
 

jbellora

Member
Licensed User
Longtime User
I don't know what you mean by "external pushbutton" but if you need to detect if the headphone has been plugged or unplugged you could use the BroadcastReceiver library.

"External pushbutton" is a mechanical switch that would be cabled to the appropiate contacts of the headphone jack. I looked at the Intents and there is a MEDIA_BUTTON that seems to be the one I need.

Thank you, your tip is very helpful!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…