I want to have a functionality of real time audio streaming on android device which is capturing audio through the MIC of the device and send it to the server. I know to sen
You can use sockets as so:
String hostname = "1.2.3.4";
int port = 865;
Socket socket = null;
try {
socket = new Socket(InetAddress.getByName(hostname), port);
} catch (Exception e) {
e.printStackTrace();
}
ParcelFileDescriptor socketedFile = ParcelFileDescriptor.fromSocket(socket);
Then set the socketedFile to the output file (socketedFile.getFileDescriptor()) of the audio recorder. This will send it up as bytes.
Alternatively to make it more stable, write out the data from the MediaRecorder to a local buffer and then have a separate thread check that buffer and write it to the socket instead, to allow for small disconnections in the socket connection.
See this question for more information: android stream audio to server
Obviously you then need to have an application running on a server to receive your bytes and turn that into audio data.