Android examples for android.media:Audio
get Max Sample Rate for AudioFormat
import android.media.AudioFormat; import android.media.AudioRecord; public class Main { public static int getMaxSampleRate() { int maxSampleRate = -1; int[] possibleSampleRates = { 48000, 44100, 22050, 16000, 11025, 8000 }; for (int i = 0; i < possibleSampleRates.length; i++) { int bufferSize = AudioRecord.getMinBufferSize(possibleSampleRates[i], AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); if (bufferSize > 0) { maxSampleRate = possibleSampleRates[i]; return maxSampleRate; }// w ww . j av a2 s. c o m } return maxSampleRate; } }