I'm trying make a simple app to record audio from MIC but I have seen examples 1000 but all give me the same error:
java.lang.RuntimeException: setAudioSource failed. at android.media.MediaRecorder._setAudioSource(Native Method)
I don't find the solution, and this occur at emulator (without MIC, I know) and my terminal (Note 4 - Android 6.0.1).
public class Audio {
private MediaRecorder myAudioRecorder;
String mFileName;
public Audio(Context contexto)
{
myAudioRecorder = new MediaRecorder();
}
public void startRecord(String name)
{
myAudioRecorder=new MediaRecorder();
myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); <== ** HERE ERROR **
myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
myAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
myAudioRecorder.setOutputFile(name);
}
public void stopRecord()
{
myAudioRecorder.stop();
myAudioRecorder.reset();
}}
Is there any way to know if another application has held the microphone?
Another thing, I add to my manifiest both permission:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
I have seen this soution too android mediaRecorder.setAudioSource failed but I continue without solution.... I don't know how I can make it.
Thanks for all.