Android AudioRecord to Server over UDP Playback Issues

Here's something you could try, instead of:

// read the data into the buffer
recorder.read(buffer, 0, buffer.length);

// place contents of buffer into the packet
packet = new DatagramPacket(buffer, buffer.length, serverAddress, PORT);

Do not expect you received fully read buffer from recorder but use actual read value instead

// read the data into the buffer
int read = recorder.read(buffer, 0, buffer.length);

// place contents of buffer into the packet
packet = new DatagramPacket(buffer, read, serverAddress, PORT);

Or something alike.