編輯:關於Android編程
private void createAudioRecord() {
for (int sampleRate : new int[]{44100, 8000, 11025, 16000, 22050, 32000,
47250, 48000}) {
for (short audioFormat : new short[]{
AudioFormat.ENCODING_PCM_16BIT,
AudioFormat.ENCODING_PCM_8BIT}) {
for (short channelConfig : new short[]{
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.CHANNEL_IN_STEREO}) {
// Try to initialize
try {
recBufSize = AudioRecord.getMinBufferSize(sampleRate,
channelConfig, audioFormat);
if (recBufSize < 0) {
continue;
}
audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
sampleRate, channelConfig, audioFormat,
recBufSize * 2);
if (audioRecord.getState() == AudioRecord.STATE_INITIALIZED) {
return;
}
audioRecord.release();
audioRecord = null;
} catch (Exception e) {
// Do nothing
}
}
}
}
throw new IllegalStateException(
"getInstance() failed : no suitable audio configurations on this device.");
}
2.常見錯誤 1.有些設備上面,即使你得到了有效的AudioRecorder實例,在audioRecord.startRecording()的時候還會報ERROR_BAD_VALUE錯誤。 這有可能是你使用了AudioManager而沒有釋放導致的。 其他錯誤都可以在網絡上找到答案。
Android 圖表繪制 achartengine 示例解析
一. AChartEngine 簡介 1. 項目地址 AChartEngine 簡介 : AChar
[Android]自定義ListView:上拉加載更多
上拉刷新,即當ListView滾動到底部的時候,再繼續拉取的時候,將出現一個提示告訴你正在加載數據,稍後提示消失,新的數據出現。在這裡,我提供一個想法:ListView自
ubuntu移植crypto++到Android平台
官方Wikihttp://www.cryptopp.com/wiki/Android_(Command_Line)這個移植比較簡單,官方直接就有文檔了,而且有現成的腳本。
Android仿斗魚領取魚丸文字驗證(二)
接著第一篇內容,來完成一下中間部分,中文驗證碼的部分,先看一下要實現的效果:一、分析功能分析一下,我們要實現一個驗證碼功能,隨機生成4個中文組合,文字隨機,文字顏色隨機,