m new to android, was just trying to record the calls. After hanging up, recording should be saved but it's not there in storage. can somebody help me with it
public void startRecording() throws IOException {
ditchRecord();
File outFile=new File(OUTPUT_FILE);
if(outFile.exists()){
outFile.delete();
}
recorder= new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(OUTPUT_FILE);
recorder.prepare();
recorder.start();
}
private void ditchRecord() {
if(recorder!=null)
recorder.release();
}
Based on the documentation,
Capturing from VOICE_CALL source requires the CAPTURE_AUDIO_OUTPUT permission. This permission is reserved for use by system components and is not available to third-party applications.
Hence, it looks like what you're trying to do is not possible, unless your app is installed as a system app, which will only work on rooted devices.
Related
I am trying to create an audio recorder app that records audio and should save audio only when users click on the save button. But the problem I am facing is that as soon as recording stops it saves automatically. And if I try to set setOutputFile to null then the app crashes.
Code
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setOutputFile(AudioSavePathInDevice);
Does Anybody know how to save that audio recording manually?
I am trying to record voip call of what's-app and some how able to trigger recording at the same time when an VOIP call is ongoing .
Trying the Below code to record the VOIP Call
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(audiofile.getAbsolutePath());
try {
recorder.prepare();
} catch (IllegalStateException e)
{
e.printStackTrace();
}
recorder.start();
but for VOIP call whats app is also using AudioRecorder with the same Audio Source and whoever either my app Recording service or whatsapp able to get an instance of recorder will run perfectly and other app stucked due to Audio Resource Busy . Any suggestion how will i record the Voip Call
I want to implement call recording in my one app, So I have used below questions for reference:
Android Recording Incoming and Outgoing Calls
How To Record Incoming Call in android programmatically?
I am using below code to record a call
recorder.reset();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
But I have also try to use different audio source and output format but it's not recording properly
its recording one-sided call sometimes, and when changing to voice_call and voice_communication its not recording calls at all
In some thread, I found that in some devices it's not working properly but I found some apps in play store which works quite good
https://play.google.com/store/apps/details?id=com.appstar.callrecorder
Brief: How to check if voice recording is already running in background in some other app.
Detail: if voice recording is already running in background from native app: Voice recorder.
Now I have implemented voice recording as one of feature in my application.
Problem: when i try recording in my app at the same time, it gives error :
: E/MediaRecorder: start failed: -38
: E/MyApp: [1162][com.sec.MyApp.multimedia.RecordMyVoice]java.lang.IllegalStateException
: E/MyApp: at android.media.MediaRecorder.start(Native Method)
: E/MyApp: at com.sec.MyApp.multimedia.RecordMyVoice.doInBackground(RecordMyVoice.java:100)
Code at 100th line in RecordMyVoice.java:
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.prepare();
mRecorder.start(); //code at 100th line
But problem is because already voice recording is running in background.
Therefore is there any way to stop voice recording if its running in some other app.
Any input would be of great help.
i've had the same Error -38, i found out that there is Another background service that uses the mic via (AudioRecord), when disabling the background service , it worked.
Check your file path, the directory must be existed.
I managed to record audio by sending intent with action MediaStore.Audio.Media.RECORD_SOUND_ACTION.
But is there a way to tell MediaStore application to automatically start recording without the need for user to press record button?
I don't see relevant parameters nor MediaStore.Audio.Media nor in MediaStore.
And same question for video...
You can directly use the MediaRecorder object to record. This way you can control when and how to start the voice recording.
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();