【发布时间】:2014-05-03 09:02:50
【问题描述】:
我在尝试添加一个对象时遇到问题。请帮忙!!!!
Vector BufferTotal = new Vector(); int n=1;
while (true) {
if(AudioRecord.ERROR_INVALID_OPERATION != 0) {
num = record.read(buffer, 0, 1024);
}
track.write(buffer,0, num);
//Writes the audio data to the audio sink for playback (streaming mode),
//or copies audio data for later playback (static buffer mode)
track.play();
buffer2=buffer.clone();
BufferTotal.add(n, buffer2.clone());
n++;
throw new IndexOutOfBoundsException("RecandPlay:Error en la posicion "+n+" de "+BufferTotal.size());
}
错误:
java.lang.ArrayIndexOutOfBoundsException: length=0; index=1
【问题讨论】:
-
请从 logcat 发布堆栈跟踪。
-
别担心,我已经解决了。我已经将 BufferTotal.add(int,byte[]) 替换为 BufferTotal.add(byte[]) 并且应用程序正常运行。谢谢!!!
标签: java android arrays vector indexoutofboundsexception