Java tutorial
//package com.java2s; //License from project: Open Source License import android.media.AudioRecord; public class Main { /** * Get a valid sample rate for the device * * @param channelConfiguration * the channel configuration * @param audioEncoding * the audio encoding * @return the valid sample rates */ public static int getValidSampleRates(int channelConfiguration, int audioEncoding) { for (int rate : new int[] { 8000, 11025, 16000, 22050, 44100 }) { // add the rates you wish to check against int bffrSize = AudioRecord.getMinBufferSize(rate, channelConfiguration, audioEncoding); if (bffrSize > 0) { return bffrSize; } } return 0; } }