I'm trying to pass audio into an android phone through the headphone jack from an external player. I am reasonably sure it can be done for two reasons:
1) The square card reader works by sending its information through the headphone jack, so it can handle information input. https://squareup.com/reader
2) In order to get the audio from the player to the phone, I will be using a normal aux-aux cable, similar to those used connecting a music player to speakers. The fact that the audio can be passed to the speakers through a simple two ring cable. I know usually the two rings are used only for output with a third ring for input, but it seems to me this would suggest they are capable of inputting without the third ring.
My problem is there doesn't seem to be any api to deal with input through the headphone jack, and no one seems to know how the square reader works, or deals with the input. It looks like AudioRecord, http://developer.android.com/reference/android/media/AudioRecord.html, could have some potential to work, but it seems to need the size to be specified ahead of time, which is not ideal.
So if anyone could help me with any information on AudioRecord and how it works, or an alternative way of dealing with the input, I'd appreciate it. Also if someone knows for sure if I am correct in thinking the two ring cable can deal with input, that would also help a lot. Thanks.
Short answer: No. The Headphone Jack is designed as an output only.
The standard aux connector size is 3.5mm, while headphone jack sizes vary from 2.5mm to 6.35. You can use a headphone jack for an aux-in, but not the other way around. Auxiliary cables are essentially used for mixing consoles.
Right click Volume icon in System Tray at right end of task bar, Open Sounds Settings, in dropdown menus at top make sure Headphones are selected and Connected for both Playback and Recording Default Devices.
SquareUp teardown by North Street Labs is a good point of reference to understand the design of the SquareUp reader. (Archived Link)
Audio Recording With a Smartphone will shed some light on the headphone rings and their configuration.
BrandonLW's GitHub source code provides the Android source code to record and decode the sound data.
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With