Recording audio on Android with examples

Click for: original source

Knowing how to effectively record audio from a phone is valuable for mobile developers, but is especially essential for apps that process media. The wide range of hardware in Android devices can make it difficult to develop applications that need to capture and play back audio. By Megan Ren.

However, Android provides several media frameworks to abstract the audio recording process, and others have developed external libraries that make it possible to incorporate high-performance audio into an application. This article will explain how to use the MediaRecorder, MediaPlayer, AudioRecord, and AudioTrack frameworks in Java, touch briefly on other options for audio capture and playback, and lastly will review their respective pros and cons.

The main content of the article:

  • What is MediaRecorder and how to use it?
  • What is MediaPlayer and how to use it?
  • What is AudioRecord and how to use it?
  • What is AudioTrack and how to use it?
  • Other options

For applications where low latency and/or high performance is vital to audio features, you could consider using libraries written in C or C++ and incorporating them in your app using the Android NDK toolset. OpenSL ES is an API that operates at a lower level, standardizing audio functionality access across platforms and allowing applications to use hardware acceleration. Follow the link to get all the details and see the table with features comparison for each option. Good read!

[Read More]

Tags android app-development kotlin ux