Many links are changed in javatpoint. If any link is not working, please delete the cookie of your browser and refresh the page.

91-9990449935

 0120-4256464

Android MediaRecorder Example

MediaRecorder class can be used to record audio and video files.

After recording the media, we can create a sound file that can be played later.

In this example, we are going to record the audio file and storing it in the external directory in 3gp format.

activity_main.xml

Drag 2 buttons from the pallete, one to start the recording and another stop the recording. Here, we are registering the view with the listener in xml file using android:onClick.

File: activity_main.xml

Activity class

File: MainActivity.java


Output:

android media recorder example output 1 android media recorder example output 2