When I try to use the microphone on Android, I can't record if another app is already using it. If you just can't record, it means that the sound you intend to record is flowing to the app holding the microphone if you're not careful. If VoIP apps run at the same time, the worst situation can be that the voice reaches only another person, not the person you are talking to. .. ..
Detects that your app cannot use the microphone and stops recording.
The flow is as follows when recording. AudioRecord
AudioRecord audioRecord = new AudioRecord(,,,,);
audioRecord.setRecordPositionupdateListener(new AudioRecord.OnRecordPositionupdateListener() {
//Processing for each frame
@Override
public void onPeriodicNotification(AudioRecord recorder) {
audioRecord.read();
}
});
audioRecord.setPositionNotificationPeriod();
audioRecord.startRecording();
audioRecord.read();
・
・
・
audioRecord.stop();
However, it seems that none of the functions return an error, even if other apps are using the microphone. .. ..
However, there was a difference with and without competition for microphone usage. If you can't get the microphone, it doesn't seem to call onPeriodicNotification, which is a callback for frame-by-frame processing.
Therefore, if onPeriodicNotification is not called after a certain period of time, it seems that it can be determined that the microphone is acquired by another app.
** Contents ** Make sure onPeriodicNotification is not called during a call on Line, Facebook messenger environment Nexus 6 (7.1.1) , Nexus 7 (6.0.1)
――Please let me know if there is a better way! ――Please let me know if you cannot detect it by this method!
Recommended Posts