Initialize the recorder
Before you can start recording, you need to create an instance ofAMRAudioRecorder with a valid directory path where audio files will be stored.
The directory must exist before initializing the recorder, otherwise you’ll get an
IllegalArgumentException.Start recording
Call thestart() method to begin recording audio:
start() method:
- Returns
trueif recording started successfully - Returns
falseif there was an error preparing the recorder - Automatically configures the MediaRecorder with AMR-NB format
- Sets the audio source to the device microphone
Check recording status
You can check if the recorder is currently recording:Stop recording
When you’re finished recording, call thestop() method:
The
stop() method automatically merges multiple audio segments if you used pause/resume. See the pause and resume guide for details.Complete example
Here’s a complete example from the sample app:Audio configuration
AMRAudioRecorder uses the following configuration by default:- Audio source:
MediaRecorder.AudioSource.MIC - Output format:
MediaRecorder.OutputFormat.AMR_NB - Audio encoder:
MediaRecorder.AudioEncoder.AMR_NB - File extension:
.amr