How to record audio using audio api in Android?

前端 未结 2 2029
遇见更好的自我
遇见更好的自我 2020-12-30 17:32

I have an LG Android Phone with Version 2.3.3. I need to connect a microphone in the headphone jack because I want to create an app that reads sound samples.

How c

2条回答
  •  粉色の甜心
    2020-12-30 18:15

    2) How can i read samples programatically?

    That I know of, In Android you can record audio using one of this two classes:

    • MediaRecorder Class

      Used to record audio and video. The recording control is based on a simple state machine

    • AudioRecord class

      The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform. This is achieved by "pulling" (reading) the data from the AudioRecord object. The application is responsible for polling the AudioRecord object in time using one of the following three methods: read(byte[], int, int), read(short[], int, int) or read(ByteBuffer, int). The choice of which method to use will be based on the audio data storage format that is the most convenient for the user of AudioRecord.

    Ps: Follow this links above to read and understand the one that best fits your needs.


    1) Which Microphone do you recommend?

    As I've mentioned on the comment placed on your question, this gets off-topic here on stackoverflow, but for the purpose of completeness:

    • How do i use a external microphone with my Galaxy Nexus?

    • Any success with external microphones for Android phones or tablets?

提交回复
热议问题