Code example for AudioManager

Methods: getProperty

0
	@TargetApi(17) 
	private int getLowLatencyOptimalSamplingRate() { 
		AudioManager manager = (AudioManager) getApplicationContext()
				.getSystemService(Context.AUDIO_SERVICE);
		return Integer.parseInt(manager
				.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
	} 
 
	private int getOptimalSamplingRate() { 
		int ret;
		if (android.os.Build.VERSION.SDK_INT >= 17)
			ret = getLowLatencyOptimalSamplingRate();
		else 
			ret = AudioTrack
					.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
 
		Log.i(TAG, "Using sampling rate: " + ret + " Hz");
		return ret;
	} 
 
	@Override