我无法通过此代码从esp8266收到任何数据 模块接收任何其他字节数据...... 它的添加权限
uses-permission android:name =“android.permission.RECORD_AUDIO”
buffersize
private int BufferSize = AudioRecord.getMinBufferSize(44100,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT);
void Recording() {
call = new AudioRecord(MediaRecorder.AudioSource.MIC, 44100, AudioFormat.CHANNEL_IN_DEFAULT, AudioFormat.ENCODING_PCM_16BIT, BufferSize);
if(CallFlag) {
call.startRecording();
}
else {
call.stop();
call.release();
}
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
Thread callmagi = new Thread(new Runnable() {
@Override
public void run() {
synchronized (this) {
byte buff[] = new byte[BufferSize];
while (CallFlag) {
int count = call.read(buff,0,BufferSize);
try {
InetAddress ip = InetAddress.getByName("192.168.43.96");
DatagramPacket db = new DatagramPacket(buff, count, ip, 9001);
clientSocket.send(db);;
// buff = null;
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
});
callmagi.start();
}