I found code for recording sound, but I always get:
The setOutputFile (FileDescriptor) method in the MediaRecorder type is not applicable for arguments (Uri)
So, how do I need to describe the file path, that it works?
// Prepare recorder source and type MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); // File to which audio should be recorded File outputFile = getFileStreamPath("output.amr"); Uri target = Uri.parse(outputFile.getAbsolutePath()); recorder.setOutputFile(target); // Get ready! recorder.prepare(); // Start recording recorder.start(); // Stop and tidy up recorder.stop(); recorder.release();
source share